Combining string functions
Nesting string functions: the inner SUBSTRING runs first, then UCASE changes its result. This gives the first letter of Name in capitals, such as an initial.
Understanding Combining string functions in IGCSE Computer Science Paper 2
What it does: SUBSTRING takes 3 characters from position 1, UCASE converts them, and the result is assigned to the STRING variable ShortCode. The innermost function is worked out first. Its result becomes the input of the outer function. LENGTH(Name) - 1 is one character fewer than the whole string. Adding 1 would ask for more characters than Name has. Every opening bracket needs a closing bracket. The nested call needs two closing brackets at the end. LENGTH must be given Name alone, and then 1 is subtracted from the number it returns: LENGTH(Name) - 1.
Common mistakes: UCASE(SUBSTRING(...)) returns a string, so the variable that stores the initial must be declared as STRING, not INTEGER. The line should be DECLARE I : STRING. A CHAR holds only one character, but Name stores a whole name that SUBSTRING must take a part of. It should be DECLARE Name : STRING.
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 347–357) 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
UCASE(SUBSTRING(Name, 1, 1))Fill in the Blanks
Spot the Error
Student with a class code? Join your class →