| preferred AP College board partner for AP classes
AP Computer Science A/Unit 4: Iteration
Start Practice TestPractice Test
About Exam
easy Solved by 2 students
While Loop Summation
< Prev
Next >

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.

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy