LENGTH: number of characters in a string
Returns an INTEGER: the number of characters in the string, including spaces. LENGTH("Happy Days") returns 10 and LENGTH("") returns 0.
Understanding LENGTH: number of characters in a string in IGCSE Computer Science Paper 2
What it does: LENGTH returns an integer (9 here), so an INTEGER variable is the correct place to store it. Name holds 7 characters including the space, so LENGTH(Name) outputs 7. Spaces count as characters. Happy (5) + space (1) + Days (4) = 10. An empty string has no characters, so its length is 0. LENGTH needs its argument in brackets: LENGTH(Name). A space is a character, so it is counted. Hi (2) + space (1) + there (5) = 8. LENGTH("cat") is the integer 3, so adding 1 gives 4. It does not join text. The characters are A, a space and B, which makes 3.
Common mistakes: LENGTH returns a whole number, so the variable that stores the result must be declared as INTEGER, not STRING. The Cambridge pseudocode function is called LENGTH, not LEN. It should be Size ← LENGTH(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 337–346) and word search (Modules 337–357).
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(Text)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →