SUBSTRING: extracting part of a string
Returns part of a string: length characters taken from the start position. SUBSTRING("Happy Days", 1, 5) gives "Happy". The result is always a string.
Understanding SUBSTRING: extracting part of a string in IGCSE Computer Science Paper 2
What it does: The start is 2 and the length is 4, so the call extracts four characters from position 2 and the result is assigned to Part with ←. Start 1 and length 1 give just the first character, and OUTPUT displays the string that SUBSTRING returns. Start and length must be positive whole numbers (integers). 2.5 is a REAL, so it is not valid. The variable should be declared as STRING (or CHAR for one character). The assigned value must match the variable's data type.
Common mistakes: The start and length are swapped. This takes 1 character from position 5, which gives "y". To get "Happy" it must start at 1 and take 5 characters: SUBSTRING(Word, 1, 5). Positions in Cambridge pseudocode start at 1, so a start of 0 is not valid. The first character is taken with SUBSTRING(Name, 1, 1).
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
SUBSTRING(<string>, <start>, <length>)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →