Unit 2 Cycle 2 Day 19: Iteration (while-loop growth)
Share
Unit 2, Selection & Iteration • Cycle 2
Day 19 Advanced Practice • Harder Difficulty
Focus: Exponential Growth
Hard
Iteration (while-loop growth)
Advanced Practice Question
Format: Iteration (while-loop growth)
What is printed?
What is printed?
"apcs-keyword">int x = "apcs-number">1;
"apcs-keyword">int steps = "apcs-number">0;
"apcs-keyword">while (x < "apcs-number">20)
{
x *= "apcs-number">2;
steps++;
}
System.out.println(steps);
Difficulty: Hard |
Topic: Iteration (while-loop growth) |
Cycle: 2 (Advanced)
Why This Answer?
x goes 1→2→4→8→16→32, which is 5 updates, so steps is 5.
Common Mistake
Watch Out!
Stopping at 16 because it "looks close" to 20; the loop continues until x is no longer < 20.
AP Exam Strategy
For multiplicative loops, simulate each update; don't approximate.
Master This Topic
This Cycle 2 HARD question tests exponential growth. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding exponential growth
- Tracing code execution accurately
- Avoiding common pitfalls
Ready for More Challenges?
Cycle 2 questions prepare you for the hardest AP CSA exam questions.
Study Games Practice FRQs