Pseudocode WHILE ... DO ... ENDWHILE and REPEAT ... UNTIL
A loop that tests its condition before each repeat, so it may run 0 times. REPEAT ... UNTIL runs the body first and tests after, so it always runs at least once.
Understanding Pseudocode WHILE ... DO ... ENDWHILE and REPEAT ... UNTIL in IGCSE Computer Science Paper 2
What it does: The check is at the end, so the INPUT runs before the first test. This is the right choice when the body must run once. The condition Count < 5 is False straight away. WHILE tests first, so the body is skipped. REPEAT repeats UNTIL the condition is True. WHILE keeps repeating as long as its condition is True. WHILE ... DO ends with ENDWHILE. NEXT is used to close a FOR loop. The condition must be able to change inside the loop, for example by adding to Total. Otherwise it never becomes False.
Common mistakes: Count goes down, so Count <= 5 is always true and the WHILE loop never ends. The body must change the variable towards ending the loop: Count ← Count + 1. REPEAT ... UNTIL does not use DO. DO belongs to WHILE ... DO. The line should just be REPEAT.
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 123–134) and word search (Modules 123–145).
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 ... DO ... ENDWHILEFill in the Blanks
Spot the Error
Student with a class code? Join your class →