Iteration inside selection
A loop written inside an IF branch only runs when that branch is chosen. If the condition is FALSE, it is skipped. NEXT ends the loop first, then ENDIF ends the IF.
Understanding Iteration inside selection in IGCSE Computer Science Paper 2
What it does: The FOR loop is closed by NEXT N first, and then ENDIF closes the IF that contains it. When Total is not above 100, the FOR loop in THEN never starts, so only the ELSE OUTPUT runs.
Common mistakes: PRINT is not a Cambridge pseudocode keyword. Inside the loop, which only runs when Mark >= 50, the statement should be OUTPUT i. Cambridge pseudocode ends a FOR loop with NEXT and the counter, not ENDFOR. It should be NEXT i, and ENDIF then closes the IF.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 389–398) and word search (Modules 379–398).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
IF...THEN FOR...NEXT...ENDIFFill in the Blanks
Spot the Error
Student with a class code? Join your class →