While Loop Summation
Which of the following best describes the contents of num1 as a result of executing the code segment?
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 contents of num1 as a result of executing the code segment?
A
The sum of all integers from num2 to num3, inclusive.
B
The sum of num2 and num3.
C
The sum of all integers from num2 to num3 - 1, inclusive.
D
The product of num2 and num3.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE