Question 11
Back to Exercise
With int n = 3;, how many times does while (n--) { … } run, and what is n afterwards?
- A 3 times, n = 0
- B 3 times, n = -1 Correct
- C 2 times, n = 0
- D 4 times, n = -1
Correct Answer: Option B
The test uses the old value and then decrements: 3, 2, 1 are true (3 passes); the test with 0 is false but still decrements, leaving n at −1.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!