Ask your own question, for FREE!
Computer Science 21 Online
OpenStudy (anonymous):

The following code is intended to calculate the sum of the first five positive odd integers. int sum = 0, k; for (k = 1; k <= 10; k += 2) { sum += k; } What is wrong with this code segment? a. The segment calculates the sum of the first four positive odd integers. b. The segment calculates the sum of the first six positive odd integers. c.The segment calculates the sum of the first seven positive odd integers. d. The variable sum is incorrectly initialized. The segment would work correctly if sum
was initialized to 1. e.The segment works as intended.

OpenStudy (woodrow73):

It's always a good idea to initialize variables. the term initialize refers to giving a variable a starting value... such as; ``` int y = 0, k = 0, z = 0, fish = 0, dog = 0; String str = "", str2 = ""; ```

OpenStudy (woodrow73):

Not doing so can lead to compilation errors - though it depends on the language.

OpenStudy (rsmith6559):

a

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!