Input validation with REPEAT…UNTIL
Ends a REPEAT loop only when Mark is valid (0 to 100). Input is asked again until it passes this range check, so the program only continues with valid data.
Understanding Input validation with REPEAT…UNTIL in IGCSE Computer Science Paper 2
What it does: The REPEAT loop is a post-condition loop: INPUT runs first and the range check comes after, so the user is always asked once. With OR, one true part is enough: a mark below 0 or above 100 is outside the range, so the error message is shown. Valid means both checks must pass, so AND is needed. With OR, any number satisfies at least one check, so every value would be accepted. A range check only tests that a value falls within allowed limits. It cannot know whether the value is the actual correct mark, but it stops impossible values like 150.
Common mistakes: OR makes the condition true for every number, because any number is either at least 0 or at most 100. The loop would accept invalid marks. A range check needs AND: UNTIL Mark>=0 AND Mark<=100. The loop must ask for a new value each time round, so line 2 should be INPUT Mark. With OUTPUT, no value is ever read and the user cannot correct a bad mark.
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
UNTIL Mark >= 0 AND Mark <= 100Fill in the Blanks
Spot the Error
Student with a class code? Join your class →