← IGCSE Computer Science Paper 2

Matching argument values to parameter types and order

Each value in a call must match its parameter in number, order and data type, so a STRING cannot go to an INTEGER parameter and values cannot be swapped or left out.

Understanding Matching argument values to parameter types and order in IGCSE Computer Science Paper 2

What it does: The STRING comes first and the INTEGER second, which matches the order and the types of the parameters. 7.5 is a REAL number, so it matches a REAL parameter. It would not match an INTEGER parameter. There are two parameters, so the call needs exactly two values. Leaving one out is an error. The computer does not fix a bad call. If the number, order or data type is wrong, the program has an error. The same rules apply to functions. N is an INTEGER parameter, so a STRING value is a data type mismatch.

Common mistakes: The call passes the whole number 42, so the parameter must be INTEGER. A STRING parameter does not match the INTEGER value in the call. It should be PROCEDURE Show(N: INTEGER). "7" in quotes is a STRING, but the parameter N is an INTEGER. The value in the call must match the parameter's data type. It should be CALL Double(7).

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
PROCEDURE Greet(Name : STRING, Age : INTEGER) Which call matches the parameters?
CALL Greet(15, "Sam")CALL Greet("Sam", 15)
Matches
CALL Greet(15, "Sam") // Greet(Name : STRING, Age : INTEGER)
↓
The values are in the wrong order: 15 is passed to the STRING parameter and "Sam" to the INTEGER parameter. Swap them to CALL Greet("Sam", 15).
Applying
Meanings
Term
CALL Name(value1, value2)
Meaning
Each value in a call must match its parameter in number, order and data type, so a STRING cannot go to an INTEGER parameter and values cannot be swapped or left out.
Practice
PROCEDURE ShowScore(Name : STRING, Score : INTEGER)
Testing
Gaps
PROCEDURE Repeat(Times : )
Check Answer
Spots
1// Show a number
2PROCEDURE Show(N: STRING)

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

The 'Seahorse' badge — Range Rider, 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. PROCEDURE Greet(Name : STRING, Age : INTEGER) Which call matches the parameters?
A. CALL Greet("Sam", 15) ✓
B. CALL Greet(15, "Sam")
The values must be in the same order as the parameters. Name is a STRING and comes first, then Age as an INTEGER.
2. PROCEDURE Add(A : INTEGER, B : INTEGER) Which call has the right number of values?
A. CALL Add(4, 5) ✓
B. CALL Add(4)
There are two parameters, so the call needs exactly two values. Leaving one out is an error.
3. PROCEDURE ShowScore(Score : INTEGER) Which call is correct?
A. CALL ShowScore(80, 90)
B. CALL ShowScore(80) ✓
There is only one parameter, so only one value can be passed. Too many values is an error.
4. PROCEDURE SetAge(Age : INTEGER) Which call passes the right data type?
A. CALL SetAge(14) ✓
B. CALL SetAge("fourteen")
A STRING cannot be passed to an INTEGER parameter. Age needs a whole number.
5. PROCEDURE SetCount(Count : INTEGER) Which call is valid?
A. CALL SetCount(7.5)
B. CALL SetCount(7) ✓
7.5 is a REAL, so it does not match an INTEGER parameter. A whole number such as 7 does.

Match the Pairs

CALL ShowTotal("five", 3) // parameter 1 is INTEGER → Error: the STRING "five" is passed to an INTEGER parameter, so the data type does not match.
CALL Rectangle(5) // needs width, height → Error: too few values, because the procedure has two parameters but the call gives only one.
Values go to parameters in order, so the first value is given to the first parameter. For PROCEDURE Greet(Name : STRING, Age : INTEGER) this call is correct. → CALL Greet("Sam", 15)
A REAL value such as 7.5 can only be passed to a parameter declared as REAL, so the parameter must be REAL, as in PROCEDURE ShowPrice(Price : REAL). → CALL ShowPrice(7.5)
CALL Greet(15, "Sam") // Greet(Name : STRING, Age : INTEGER) → The values are in the wrong order: 15 is passed to the STRING parameter and "Sam" to the INTEGER parameter. Swap them to CALL Greet("Sam", 15).
CALL SetScore(10, 20, 30) // SetScore(A : INTEGER, B : INTEGER) → Too many values: three values are given for two parameters. Remove one value, for example CALL SetScore(10, 20).

Key Term

CALL Name(value1, value2)
Each value in a call must match its parameter in number, order and data type, so a STRING cannot go to an INTEGER parameter and values cannot be swapped or left out.

Fill in the Blanks

1. PROCEDURE Repeat(Times : INTEGER) CALL Repeat(5)
Hint: Type the data type that matches the whole number passed in the call.
2. PROCEDURE Area(Len : INTEGER, Wide : REAL) CALL Area(5, 2.5)
Hint: Type the data type that suits the second value, which has a decimal part.
3. PROCEDURE Show(Name : STRING, Age : INTEGER) CALL Show("Ann", 14)
Hint: Type the keyword that starts a procedure call. The two values already match the parameters in number, order and type.
4. FUNCTION Cost(Qty : INTEGER, Price : REAL) Total ← Cost(2, 1.5)
Hint: Type the data type for the second parameter so it matches the second value in the call.
5. PROCEDURE Score(Mark : INTEGER, Team : STRING ) CALL Score(80, "Red")
Hint: Type the data type of the second parameter. The values in the call must arrive in the same order.

Spot the Error

Question 1
A // Show a number
B PROCEDURE Show(N: STRING)
C OUTPUT N
D ENDPROCEDURE
E CALL Show(42)
Line B — The call passes the whole number 42, so the parameter must be INTEGER. A STRING parameter does not match the INTEGER value in the call. It should be PROCEDURE Show(N: INTEGER).
Question 2
A PROCEDURE Double(N: INTEGER)
B OUTPUT N * 2
C ENDPROCEDURE
D CALL Double("7")
Line D — "7" in quotes is a STRING, but the parameter N is an INTEGER. The value in the call must match the parameter's data type. It should be CALL Double(7).
Question 3
A // Show a grade, then a mark
B // Called as CALL Go('A', 7.5)
C PROCEDURE Go(N: REAL, C: CHAR)
D OUTPUT C, N
E ENDPROCEDURE
F CALL Go('A', 7.5)
Line C — The call passes the letter first and the number second, so the parameters must be in the same order. Here they are swapped, so 'A' would go to a REAL parameter. It should be PROCEDURE Go(C: CHAR, N: REAL).
Question 4
A PROCEDURE Half(N: INTEGER)
B OUTPUT N / 2
C ENDPROCEDURE
D CALL Half(7.5)
Line A — The call passes 7.5, which is a REAL number with a decimal part. An INTEGER parameter cannot accept it. It should be PROCEDURE Half(N: REAL).
Question 5
A W ← 2.5
B H ← 4.0
C PROCEDURE Go(A: REAL)
D OUTPUT A * B
E ENDPROCEDURE
F CALL Go(W, H)
Line C — The call passes two values (W and H), so the procedure needs two parameters. With only one parameter there are too many values, and B is never defined. It should be PROCEDURE Go(A: REAL, B: REAL).

Student with a class code? Join your class →