Choosing the return data type of a function
Keyword in a function header, followed by a data type such as INTEGER, REAL, STRING or BOOLEAN. The value sent back by RETURN must be of that same type.
Understanding Choosing the return data type of a function in IGCSE Computer Science Paper 2
What it does: A count is always a whole number, so INTEGER is the type that matches the value sent back by RETURN. Text is stored as a STRING, so the header must say RETURNS STRING to match the text value returned. The type depends on the value being returned, not the parameter. A comparison gives TRUE or FALSE, so BOOLEAN is correct. The total is a number with decimal places, so it is REAL. STRING is for text.
Common mistakes: The function returns 15, which is a whole number, but the header says STRING. The header should say RETURNS INTEGER so it matches the value sent back. RETURN "Cost" sends back a STRING, but the header says RETURNS REAL. It should be RETURN Cost, which sends back the REAL value 4.5.
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 409–418) and word search (Modules 399–418).
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
RETURNSFill in the Blanks
Spot the Error
Student with a class code? Join your class →