AP CSA Unit 2 Day 20: Iteration Accumulation

Unit 2, Selection & Iteration • Cycle 2
Day 20 Advanced Practice • Harder Difficulty
Focus: Zero-Based Accumulation Hard Iteration (accumulation)

Advanced Practice Question

Format: Iteration (accumulation)

What is printed?
int sum = 0;
for (int i = 1; i <= 5; i++) {
    sum += i;
}
System.out.println(sum);
Difficulty: Hard | Topic: Iteration (accumulation) | Cycle: 2 (Advanced)
Why This Answer?

The loop adds 0 + 1 + 2 + 3 + 4 = 10.

Common Mistake
Watch Out!

Forgetting that starting at 0 still includes 4 because of `<= 4`.

AP Exam Strategy

Check both the start value and whether the end is inclusive.

Master This Topic

This Cycle 2 HARD question tests zero-based accumulation. Review Unit 2 concepts to build mastery of selection and iteration.

  • Understanding zero-based accumulation
  • 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.