Unit 2 Cycle 2 Day 11: Iteration (nested loop count)
Share
Unit 2, Selection & Iteration • Cycle 2
Day 11 Advanced Practice • Harder Difficulty
Focus: Nested Loop Count
Hard
Iteration (nested loop count)
Advanced Practice Question
Format: Iteration (nested loop count)
What is printed?
What is printed?
"apcs-keyword">int c = "apcs-number">0;
"apcs-keyword">for ("apcs-keyword">int i = "apcs-number">0; i < "apcs-number">3; i++)
{
"apcs-keyword">for ("apcs-keyword">int j = "apcs-number">1; j <= "apcs-number">2; j++)
{
c++;
}
}
System.out.println(c);
Difficulty: Hard |
Topic: Iteration (nested loop count) |
Cycle: 2 (Advanced)
Why This Answer?
Outer loop runs 3 times. Inner loop runs 2 times each outer iteration. Total increments = 3 × 2 = 6.
Common Mistake
Watch Out!
Multiplying the wrong bounds (like 3 × 3) or missing that inner loop is `<= 2` (two iterations).
AP Exam Strategy
Count inner iterations first, then multiply by outer iterations.
Master This Topic
This Cycle 2 HARD question tests nested loop count. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding nested loop count
- 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