WHILE versus REPEAT
WHILE tests first, so its body may never run, and it loops while the condition is TRUE. REPEAT tests after the body, so it runs at least once, and it stops when the condition is TRUE.
Understanding WHILE versus REPEAT in IGCSE Computer Science Paper 2
What it does: Both loops keep asking until Num is positive. WHILE uses Num <= 0 (keep going) and UNTIL uses Num > 0 (stop), so the conditions are opposites. Total < 5 is FALSE on the first test, so the WHILE loop skips its body and nothing is output. WHILE continues on TRUE. REPEAT stops on TRUE. This is why the condition must be reversed when you rewrite one as the other. The user must be asked at least once, so the test belongs after the body. REPEAT guarantees the body runs once before checking.
Common mistakes: REPEAT stops when the condition is TRUE. Count <= 3 is a WHILE-style 'keep going' condition, so the loop would stop after one pass. It should be UNTIL Count > 3. A WHILE loop must end with ENDWHILE. UNTIL belongs to a REPEAT loop. Line 4 should be ENDWHILE.
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
WHILE vs REPEATFill in the Blanks
Spot the Error
Student with a class code? Join your class →