Tracing a validation algorithm
Step through a validation loop with valid and invalid inputs, recording each rejected value, the error message output and the value finally accepted in a trace table.
Understanding Tracing a validation algorithm in IGCSE Computer Science Paper 2
What it does: 150 and -4 are abnormal data, so the loop body runs twice and outputs the error message twice. 35 is normal data, so the loop ends and 35 is accepted. Each INPUT inside the loop gives a new value for Age, so a new row or entry is recorded. The last value in the column is the accepted one. Messages displayed by the program are OUTPUT. INPUT is only for values the user types. The loop repeats until a valid value is entered, however many attempts that takes. The UNTIL condition is the range check. The loop only stops when it is true, so every invalid input makes the loop repeat.
Common mistakes: Line 2 must read the first attempt with INPUT Age. OUTPUT only displays a value, so the loop would test an Age that was never entered. The trace table's input column would stay empty. The variable must be Password, the same name used in the length check and the UNTIL condition. Pass is a different variable, so the tested value never matches the value entered. It should be INPUT Password.
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 83–92) and word search (Modules 71–92).
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
Tracing a validation loopFill in the Blanks
Spot the Error
Student with a class code? Join your class →