LENGTH function
Returns the number of characters in a string as an integer, counting spaces. LENGTH("Happy Days") returns 10. Used in length checks.
Understanding LENGTH function in IGCSE Computer Science Paper 2
What it does: LENGTH returns an integer, so the result can be assigned to a variable with ←. A length check uses LENGTH in a condition. Using <> 4 catches any PIN that is too short or too long. The space between the two words counts as a character: Happy (5) + space (1) + Days (4) = 10. LENGTH counts the characters in a string and gives back a whole number (INTEGER). Cambridge pseudocode writes the function name in capitals, followed by the string in brackets: LENGTH(Password). H, i, space, t, h, e, r, e = 8 characters. Spaces are counted. At least 8 means 8 or more, so use >=. Using <= would accept only passwords of 8 characters or fewer.
Common mistakes: The Cambridge pseudocode function is called LENGTH, not LEN. The line should be OUTPUT LENGTH(Word). LENGTH is a function, so its argument must be inside brackets. The line should be Size ← LENGTH(Word).
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 37–46) and word search (Modules 27–46).
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(<string>)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →