Pseudocode for validating input
A loop that reads input, tests it (presence, type, range or length), then shows an error message and asks again until the input passes the check.
Understanding Pseudocode for validating input in QCE Digital Solutions Unit 3
What it does: The loop body prints an error message and re-reads the input, so the check is repeated until the score is valid. An age is invalid if it is below 12 OR above 18. No number can be both below 12 and above 18, so AND would never repeat the loop. A presence check tests that something was entered. An empty string means the user left the input blank. Comparing to 100 is a range check, not a presence check.
Common mistakes: No age can be below 1 and above 120 at once, so the loop never runs and bad input gets through. Use 'or' so the loop repeats when the age is outside the range. A presence check should loop while the name is empty (name = ""). With <> the loop runs when a name has been entered, and it stops when the input is blank. It should be: while name = "".
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 194–250) and word search (Modules 194–337).
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 input is invalidFill in the Blanks
Spot the Error
Student with a class code? Join your class →