← IGCSE Computer Science Paper 2

Writing exam answers about procedures and functions

Keyword in a FUNCTION header giving the data type of the value sent back, e.g. FUNCTION Area(r : REAL) RETURNS REAL. End with ENDFUNCTION. Never use CALL for a function.

Understanding Writing exam answers about procedures and functions in IGCSE Computer Science Paper 2

What it does: Procedures are started using CALL followed by the name and brackets. They carry out a task without returning a value. A function call is used as part of an expression, such as an assignment, because it gives back a value. CALL is never used for a function. A function starts with FUNCTION and must finish with ENDFUNCTION. ENDPROCEDURE only closes a procedure. RETURN is the statement in the body. RETURNS appears only in the header to give the data type. The key difference is that a function returns a value, whereas a procedure does not. The second answer describes a global variable. A local variable exists only within the subroutine where it is declared.

Common mistakes: The function header must use the keyword RETURNS (with an S) before the data type. It should be FUNCTION Pi() RETURNS REAL. RETURN is only used inside the body to send the value back. A procedure must be closed with ENDPROCEDURE, not ENDFUNCTION. Each block ends with the keyword that matches the one that started it.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 439–448) and word search (Modules 439–458).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which is the correct Cambridge pseudocode header for a function that gives back a whole number?
FUNCTION Double(n : INTEGER) RETURN INTEGERFUNCTION Double(n : INTEGER) RETURNS INTEGER
Matches
CALL Area(5.0)
↓
CALL is used with a function. Functions return a value, so the call should be used in an expression such as result ← Area(5.0).
Applying
Meanings
Term
RETURNS
Meaning
Keyword in a FUNCTION header giving the data type of the value sent back, e.g. FUNCTION Area(r : REAL) RETURNS REAL. End with ENDFUNCTION. Never use CALL for a function.
Practice
FUNCTION Area(Radius : REAL) RETURNS REAL
Testing
Gaps
FUNCTION Area(r : REAL) REAL
Check Answer
Spots
1FUNCTION Pi() RETURN REAL
2 RETURN 3.14

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'African Wild Dog' badge — Savannah Streak, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which is the correct Cambridge pseudocode header for a function that gives back a whole number?
A. FUNCTION Double(n : INTEGER) RETURN INTEGER
B. FUNCTION Double(n : INTEGER) RETURNS INTEGER ✓
The function header uses RETURNS plus a data type. RETURN (no S) is the statement used inside the body to send the value back.
2. Which line correctly ends a function?
A. ENDFUNCTION ✓
B. ENDPROCEDURE
A function starts with FUNCTION and must finish with ENDFUNCTION. ENDPROCEDURE only closes a procedure.
3. Which statement inside a function body sends the value back to the caller?
A. RETURNS Total
B. RETURN Total ✓
RETURN is the statement in the body. RETURNS appears only in the header to give the data type.
4. Which is the correct way to use the function Area in a program?
A. OUTPUT Area(5.0) ✓
B. CALL Area(5.0)
A function call is used inside an expression or OUTPUT, or stored in a variable. CALL is only for procedures.
5. Which exam sentence defines a function correctly?
A. A subroutine that returns a value to the part of the program that called it. ✓
B. A subroutine that never sends a value back to the program.
The key difference is that a function returns a value, whereas a procedure does not.

Match the Pairs

FUNCTION Double(n : INTEGER) RETURNS INTEGER → The header of a function: RETURNS gives the data type of the value sent back to the caller
ENDPROCEDURE → The keyword that closes a procedure; a function is closed with ENDFUNCTION instead
A procedure is run with the CALL keyword, and it does not return a value → CALL ShowMenu()
A function sends a value back with RETURN, so its call is used inside an expression, not with CALL → total ← AddTax(price)
CALL Area(5.0) → CALL is used with a function. Functions return a value, so the call should be used in an expression such as result ← Area(5.0).
FUNCTION Area(r : REAL) RETURN r * r * 3.14 ENDFUNCTION → The header is missing RETURNS REAL, so the data type of the returned value is not stated.

Key Term

RETURNS
Keyword in a FUNCTION header giving the data type of the value sent back, e.g. FUNCTION Area(r : REAL) RETURNS REAL. End with ENDFUNCTION. Never use CALL for a function.

Fill in the Blanks

1. FUNCTION Area(r : REAL) RETURNS REAL
Hint: Type the keyword in a function header that introduces the data type of the value sent back.
2. FUNCTION IsEven(n : INTEGER) RETURNS BOOLEAN RETURN n MOD 2 = 0 ENDFUNCTION
Hint: Type the return data type. The function answers a true or false question.
3. PROCEDURE ShowScore(s : INTEGER) OUTPUT s ENDPROCEDURE
Hint: Type the keyword that closes a procedure.
4. FUNCTION Square(n : INTEGER) RETURNS INTEGER RETURN n * n ENDFUNCTION
Hint: Type the keyword inside a function body that sends a value back to the caller.
5. CALL ShowScore(85)
Hint: Type the keyword used to run a procedure. It is never used for a function.

Spot the Error

Question 1
A FUNCTION Pi() RETURN REAL
B RETURN 3.14
C ENDFUNCTION
Line A — The function header must use the keyword RETURNS (with an S) before the data type. It should be FUNCTION Pi() RETURNS REAL. RETURN is only used inside the body to send the value back.
Question 2
A PROCEDURE ShowMenu()
B OUTPUT "1. Play"
C ENDFUNCTION
Line C — A procedure must be closed with ENDPROCEDURE, not ENDFUNCTION. Each block ends with the keyword that matches the one that started it.
Question 3
A DECLARE score : INTEGER
B score ← 0
C score ← CALL GetScore()
D OUTPUT score
Line C — CALL is only used for procedures. A function is used in an expression, so the line should be score ← GetScore().
Question 4
A FUNCTION Pi() RETURNS REAL
B OUTPUT 3.14
C ENDFUNCTION
Line B — A function must send its value back with RETURN. OUTPUT only displays a value and returns nothing. It should be RETURN 3.14.
Question 5
A PROCEDURE Greet(n : STRING)
B OUTPUT "Hi ", n
C ENDPROCEDURE
D Greet("Sam")
Line D — A procedure must be run using the keyword CALL. It should be CALL Greet("Sam").

Student with a class code? Join your class →