AP CSA Unit 2 Day 23: Iteration While Loop Tracing

Unit 2, Selection & Iteration • Cycle 2
Day 23 Advanced Practice • Harder Difficulty
Focus: Loop Termination Hard Iteration (while-loop tracing)

Advanced Practice Question

Format: Iteration (while-loop tracing)

What is printed?
int x = 1;
while (x < 10) {
    System.out.print(x + " ");
    x = x * 2;
}
Difficulty: Hard | Topic: Iteration (while-loop tracing) | Cycle: 2 (Advanced)
Why This Answer?

x goes 10→6→2→-2, so the loop runs 3 times and prints 3.

Common Mistake
Watch Out!

Stopping at x=2 and forgetting the loop runs one more time before x becomes ≤ 0.

AP Exam Strategy

The condition is checked before each iteration; updates happen inside.

Master This Topic

This Cycle 2 HARD question tests loop termination. Review Unit 2 concepts to build mastery of selection and iteration.

  • Understanding loop termination
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 2 Study Guide

Ready for More Challenges?

Cycle 2 questions prepare you for the hardest AP CSA exam questions.

Study Games Practice FRQs
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.