Difficulty: Easy
Correct Answer: 20 16 12 8 4 0 -4 -8 -12
Explanation:
Introduction / Context:
This program combines an infinite for loop with in-body control using if/else and a break. The test checks whether you correctly follow the order of actions inside the loop: print first, then decide whether to decrement or exit. Many learners get tripped by when the break runs relative to the last printed value.
Given Data / Assumptions:
Concept / Approach:
Remember the exact sequence per iteration: (1) print current i, (2) evaluate i >= -10, (3) either decrement by 4 or break. Because printing occurs before the break check, the terminal value that violates the condition can still be printed on the following iteration's start if it is assigned after the check in the previous round.
Step-by-Step Solution:
Verification / Alternative check:
Count steps: arithmetic progression descending by 4 until passing -10; the last printed number will be -12 because printing precedes the break test.
Why Other Options Are Wrong:
Common Pitfalls:
Checking the break before printing, or assuming the loop stops at -8. The code prints -12 then exits.
Final Answer:
20 16 12 8 4 0 -4 -8 -12
Discussion & Comments