Defining a function with parameters
A function header lists each parameter in brackets as name:TYPE, then RETURNS and the return type. The body uses the parameters in a RETURN expression and ends with ENDFUNCTION.
Understanding Defining a function with parameters in IGCSE Computer Science Paper 2
What it does: The single parameter Num is written as Num:INTEGER in the brackets, followed by RETURNS INTEGER. This function has three parameters, returns their total and is closed with ENDFUNCTION. The header uses RETURNS followed by the data type. RETURN (without the S) is the statement used inside the body. Every parameter needs its own data type, so each one is written as name:TYPE and they are separated by commas. A function must state what type of value it returns, so RETURNS and a type must follow the parameter list.
Common mistakes: A function must finish with ENDFUNCTION, not ENDPROCEDURE. ENDPROCEDURE is only used to close a procedure. The RETURN expression can only use the parameters in the header. C is not a parameter, so it should be RETURN A + B.
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
FUNCTION SumSquare(Number1:INTEGER, Number2:INTEGER) RETURNS INTEGERFill in the Blanks
Spot the Error
Student with a class code? Join your class →