Choosing the right loop
Use FOR when the number of repeats is known, WHILE when the body might run zero times (such as reading until a sentinel), and REPEAT when the body must run at least once (such as validation).
Understanding Choosing the right loop in IGCSE Computer Science Paper 2
What it does: WHILE tests the condition before the body, so if the first value is the sentinel the body runs zero times. REPEAT ... UNTIL checks at the end, so the prompt always appears at least once, which is what validation needs. The number of repeats is known (12), so a count-controlled FOR loop is the best choice.
Common mistakes: The count is known to be 5, so FOR is the right loop. But TO 4 makes it run only 4 times. It should be FOR Count ← 1 TO 5. A WHILE loop tests its condition before the first pass, so the first value must be read with INPUT Num before the loop. OUTPUT does not read a value.
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 166–175) and word search (Modules 166–187).
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
FOR / WHILE / REPEATFill in the Blanks
Spot the Error
Student with a class code? Join your class →