AP CSA Unit 2 Day 10: Iteration Accumulation
Share
Unit 2, Selection & Iteration • Cycle 2
Day 10 Advanced Practice • Harder Difficulty
Focus: Accumulator Pattern
Hard
Iteration (accumulation)
Advanced Practice Question
Format: Iteration (accumulation)
What is printed?
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 1 + 2 + 3 + 4 = 10.
Common Mistake
Watch Out!
Forgetting the loop includes 4 because of `<= 4`.
AP Exam Strategy
When you see `<=`, include the endpoint in your sum.
Master This Topic
This Cycle 2 HARD question tests accumulator pattern. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding accumulator pattern
- 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