← IGCSE Computer Science Paper 2

Using a function call in OUTPUT

Puts a function call inside OUTPUT. The function runs first, then the value it RETURNs is displayed. Text can be added: OUTPUT "Sum = ", SumSquare(10, 20).

Understanding Using a function call in OUTPUT in IGCSE Computer Science Paper 2

What it does: The call SumSquare(a, b) is used as the value to display, with no variable needed in between. The returned value is saved in Total first. OUTPUT then displays the variable, which holds the function's value. Items in an OUTPUT statement are separated by commas. Without the comma the statement is not valid.

Common mistakes: The function call is missing its closing bracket. It should be OUTPUT "Sum = ", Add(10, 20). CALL is only used for procedures. A function is called by writing its name and arguments, so it should be Total ← SumSquare(10, 20).

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 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.

Learning
Duo
Which line displays the value returned by the function SumSquare?
OUTPUT SumSquare(10, 20)OUTPUT SumSquare
Matches
OUTPUT "Sum of squares = " SumSquare(10, 20)
↓
There is no comma between the text and the function call, so the two items are not separated correctly
Applying
Meanings
Term
OUTPUT SumSquare(10, 20)
Meaning
Puts a function call inside OUTPUT. The function runs first, then the value it RETURNs is displayed. Text can be added: OUTPUT "Sum = ", SumSquare(10, 20).
Practice
FUNCTION SumSquare(A : INTEGER, B : INTEGER) RETURNS INTEGER
Testing
Gaps
SumSquare(10, 20)
Check Answer
Spots
1OUTPUT "Sum = ", Add(10, 20
2OUTPUT "Next = ", Add(3, 4)

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

The 'Roadrunner' badge — Streak Runner, 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 line displays the value returned by the function SumSquare?
A. OUTPUT SumSquare
B. OUTPUT SumSquare(10, 20) ✓
The function call needs its brackets and arguments. The function runs, RETURNs a value, and OUTPUT displays that value.
2. What happens first when this line runs? OUTPUT SumSquare(10, 20)
A. The function runs and returns a value ✓
B. OUTPUT displays the words SumSquare(10, 20)
The function call is evaluated first. OUTPUT then displays the value that was returned, not the function call itself.
3. Which statement shows text and a function result together?
A. OUTPUT "Sum of squares = ", SumSquare(10, 20) ✓
B. OUTPUT "Sum of squares = " SumSquare(10, 20)
Items in an OUTPUT statement are separated by commas. Without the comma the statement is not valid.
4. Which is the correct way to put a function call inside OUTPUT?
A. OUTPUT CALL SumSquare(10, 20)
B. OUTPUT SumSquare(10, 20) ✓
CALL is only used for procedures. A function call is used as a value, so it goes straight into OUTPUT with no CALL.
5. A function Double(n) RETURNs n * 2. What does OUTPUT "Result = ", Double(4) display?
A. Result = 8 ✓
B. Result = Double(4)
Double(4) is worked out first and gives 8. OUTPUT then shows the text followed by 8.

Match the Pairs

OUTPUT SumSquare(10, 20) → Calls the function SumSquare with 10 and 20, then displays the value it returns
OUTPUT "Sum of squares = ", SumSquare(10, 20) → Displays the text first, then the value returned by the function call, on the same line
A function call can be placed straight into OUTPUT, so there is no need to store the result first → OUTPUT SumSquare(a, b)
A function result can be stored in a variable, and then the variable is displayed with OUTPUT → Total ← SumSquare(10, 20) OUTPUT Total
OUTPUT "Sum of squares = " SumSquare(10, 20) → There is no comma between the text and the function call, so the two items are not separated correctly
OUTPUT "Sum of squares = ", SumSquare → The function name is written without brackets and arguments, so the function is not called

Key Term

OUTPUT SumSquare(10, 20)
Puts a function call inside OUTPUT. The function runs first, then the value it RETURNs is displayed. Text can be added: OUTPUT "Sum = ", SumSquare(10, 20).

Fill in the Blanks

1. OUTPUT SumSquare(10, 20)
Hint: Type the keyword that displays a value on the screen.
2. OUTPUT "Sum of squares = ", SumSquare(10, 20)
Hint: Type the name of the function being called inside OUTPUT.
3. Total ← SumSquare(10, 20) OUTPUT "Sum of squares = ", Total
Hint: Type the variable that holds the value the function returned.
4. a ← 3 OUTPUT "Sum of squares = ", SumSquare(a, 4)
Hint: Type the variable that is passed as the first argument.
5. b ← 20 OUTPUT "Sum of squares = ", SumSquare(10, b)
Hint: Type the variable that supplies the second argument in the call.

Spot the Error

Question 1
A OUTPUT "Sum = ", Add(10, 20
B OUTPUT "Next = ", Add(3, 4)
C OUTPUT "Last = ", Add(5, 6)
Line A — The function call is missing its closing bracket. It should be OUTPUT "Sum = ", Add(10, 20).
Question 2
A DECLARE Total : INTEGER
B Total ← CALL SumSquare(10, 20)
C OUTPUT "Sum = ", Total
Line B — CALL is only used for procedures. A function is called by writing its name and arguments, so it should be Total ← SumSquare(10, 20).
Question 3
A FUNCTION Ten() RETURNS INTEGER
B RETURN 10
C ENDFUNCTION
D OUTPUT "Ten = ", Ten
Line D — A function call needs brackets, even when there are no parameters. Without them Ten is not called, so it should be Ten().
Question 4
A Len ← 4
B Wid ← 6
C Size ← Area(Len, Wid)
D OUTPUT "Area = ", "Size"
Line D — Quotes make Size a piece of text, so the word Size would be displayed. Without quotes, OUTPUT displays the value stored in the variable: OUTPUT "Area = ", Size.
Question 5
A DECLARE N : INTEGER
B N ← 7
C OUTPUT "Cube = , Cube(N)
Line C — The closing quote after the text is missing, so the function call becomes part of the string and is never run. It should be OUTPUT "Cube = ", Cube(N).

Student with a class code? Join your class →