Validating input with a REPEAT loop
A validation loop: it asks for INPUT again and again until the value passes the check (here a range check), so invalid data never enters the algorithm.
Understanding Validating input with a REPEAT loop in IGCSE Computer Science Paper 2
What it does: The IF inside the loop outputs an error message for each invalid value, and the UNTIL condition only ends the loop when the value is valid. A length check uses LENGTH(Password) to count the characters. Comparing the text itself to 8 does not check its length. The REPEAT loop re-reads the input until the UNTIL range check is true, which is validation of the input. Valid marks must be at least 0 and at most 100 at the same time, so the two tests need AND to be joined.
Common mistakes: With OR the condition is true for every number, so the loop stops straight away and invalid values get through. A range check needs AND: UNTIL Num >= 1 AND Num <= 10. The loop body must ask for the value again with INPUT. OUTPUT never reads a new Age, so the check cannot be passed. Line 2 should be INPUT Age.
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 254–264) and word search (Modules 254–274).
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
REPEAT INPUT Mark UNTIL Mark >= 0 AND Mark <= 100Fill in the Blanks
Spot the Error
Student with a class code? Join your class →