Length check
A length check tests the number of characters in an input is the required length or within a limit, using LENGTH, e.g. a password of at least 8 characters or a PIN of exactly 4.
Understanding Length check in IGCSE Computer Science Paper 2
What it does: <= 12 accepts lengths of 12 or fewer and rejects anything longer, which is a maximum length check. AND means both conditions must be true, so the length must be between 6 and 12 inclusive. A length check tests the number of characters in the input. A range check tests the size of a number. Exactly 4 needs =. Using > 4 would reject a correct 4-digit PIN. A maximum length uses <=. Using >= 12 would only accept names of 12 or more characters. Validation checks only that data is reasonable. A wrong 4-digit PIN still passes a length check.
Common mistakes: A password is text, so it must be declared as STRING. LENGTH counts the characters in a string, so Password cannot be an INTEGER. The line should be DECLARE Password : STRING. A length check must test the number of characters, not the value typed. It should be IF LENGTH(PIN) = 4 THEN, so a PIN such as 1234 passes because it has exactly 4 characters.
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 47–57) and word search (Modules 47–70).
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
LENGTH(Password) >= 8Fill in the Blanks
Spot the Error
Student with a class code? Join your class →