Unit 2 Cycle 2 Day 18: Iteration (for-loop count)

Unit 2, Selection & Iteration • Cycle 2
Day 18 Advanced Practice • Harder Difficulty
Focus: Loop Step Count Hard Iteration (for-loop count)

Advanced Practice Question

Format: Iteration (for-loop count)

What is printed?
"apcs-keyword">int c = "apcs-number">0;

"apcs-keyword">for ("apcs-keyword">int i = "apcs-number">1; i <= "apcs-number">10; i += "apcs-number">2)
{
    c++;
}

System.out.println(c);
Difficulty: Hard  |  Topic: Iteration (for-loop count)  |  Cycle: 2 (Advanced)
Why This Answer?

`i` values are 1, 3, 5, 7, 9 (five iterations). So c is 5.

Common Mistake
Watch Out!

Including 11 or assuming `<= 10` means 10 is visited (it's not with step 2 from 1).

AP Exam Strategy

List the i-values for stepped loops; endpoints aren't always hit.

Master This Topic

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

  • Understanding loop step count
  • 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.