Choosing count-controlled, pre-condition or post-condition loops
Choose FOR when the number of repeats is known, WHILE when the loop may run zero times, and REPEAT...UNTIL when the loop must run at least once.
Understanding Choosing count-controlled, pre-condition or post-condition loops in IGCSE Computer Science Paper 2
What it does: WHILE tests the condition before the body, so if the first input is the rogue value the loop never runs. Validation needs the input to be taken once before it can be checked, so REPEAT...UNTIL is the best choice. The number of repeats (12) is known in advance, so a count-controlled FOR loop is the best choice.
Common mistakes: The number of repeats is known (10), so FOR is the right loop. A FOR loop uses TO to give the end value, not UNTIL. It should be FOR Count <- 1 TO 10. A WHILE loop that reads until a rogue value must keep going while the value is NOT the rogue value. It should be WHILE Score <> -1 DO. As written, the loop never runs for normal scores.
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 379–388) 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
FOR, WHILE or REPEATFill in the Blanks
Spot the Error
Student with a class code? Join your class →