Advanced Placement (AP)

The following code is intended to calculate the sum of the first five positive even integers starting at 2.

int sum = 2;
int k;
for(k = 4; k < = 12; k += 2)
{
sum += k;
}

what is wrong with this code segment?

the segment calculates the sum of the first four positive even integers.
the segment calculates the sum of the first six positive even integers.
the segment calculates the sum of the first seven positive even integers.
the variable sum is incorrectly initialized. the segment would work correctly if sum was initialized to 0.
the segment works as intended.

answer
Answers: 3

Similar questions

Do you know the correct answer?
The following code is intended to calculate the sum of the first five positive even integers startin...

Questions in other subjects: