While Loop Summation
Consider the following code segment. Assume that num3 > num2 > 0.
int num1 = 0;
int num2 = /* initial value not shown */;
int num3 = /* initial value not shown */;
while (num2 < num3)
{
num1 += num2;
num2++;
}
Which of the following best describes the final value of num1 after the code segment is executed?
A
The sum of all integers from num2 to num3 - 1, inclusive.
B
The product of num2 and num3.
C
The sum of all integers from num2 to num3, inclusive.
D
The sum of num2 and num3.
Question Leaderboard
Not enough data yet to show leaderboard.
