AP CSA Unit 2 Day 27: Iteration Selection Nested Filtering
Share
Unit 2, Selection & Iteration • Cycle 2
Day 27 Advanced Practice • Harder Difficulty
Focus: Nested Filtering
Hard
Iteration + Selection (nested filtering)
Advanced Practice Question
Format: Iteration + Selection (nested filtering)
What is printed?
What is printed?
for (int i = 1; i <= 20; i++) {
if (i % 2 == 0) {
if (i % 5 == 0) {
System.out.print(i + " ");
}
}
}
Difficulty: Hard |
Topic: Iteration + Selection (nested filtering) |
Cycle: 2 (Advanced)
Why This Answer?
For each i, odd j values are 1 and 3, so c increments 2 times per outer iteration. Two outer iterations → 4.
Common Mistake
Watch Out!
Counting all j values (4 per i) instead of only odd j values (2 per i).
AP Exam Strategy
When a condition filters iterations, count only the values that pass.
Master This Topic
This Cycle 2 HARD question tests nested filtering. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding nested filtering
- 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