← IGCSE Computer Science Paper 2

Defining a procedure with one parameter

Defines a procedure with one parameter. In the brackets after the name, write the parameter identifier, a colon, then its data type. Size is used inside the body.

Understanding Defining a procedure with one parameter in IGCSE Computer Science Paper 2

What it does: Inside the body between PROCEDURE and ENDPROCEDURE, the parameter name Size is used like a variable to output its value. The parameter identifier comes first, then a colon, then the data type: Size : INTEGER. A procedure starts with PROCEDURE and finishes with ENDPROCEDURE. ENDFUNCTION is for functions.

Common mistakes: The parameter is called Size, so the loop must use Size. Length is not defined anywhere. It should be FOR Count ← 1 TO Size. A procedure must finish with ENDPROCEDURE. ENDFUNCTION is used to close a function.

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 399–408) 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 header correctly defines a procedure with one parameter called Size?
PROCEDURE Line(Size : INTEGER)PROCEDURE Line(INTEGER : Size)
Matches
PROCEDURE Line(Size INTEGER)
↓
The colon is missing between the parameter name and its data type. It should be Size : INTEGER.
Applying
Meanings
Term
PROCEDURE Line(Size : INTEGER)
Meaning
Defines a procedure with one parameter. In the brackets after the name, write the parameter identifier, a colon, then its data type. Size is used inside the body.
Practice
PROCEDURE Line(Size : INTEGER)
Testing
Gaps
PROCEDURE Line(Size : )
Check Answer
Spots
1PROCEDURE Line(Size : INTEGER)
2 FOR Count ← 1 TO Length

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

The 'Moon Jellyfish' badge — Orbital 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 header correctly defines a procedure with one parameter called Size?
A. PROCEDURE Line(Size : INTEGER) ✓
B. PROCEDURE Line(INTEGER : Size)
The parameter identifier comes first, then a colon, then the data type: Size : INTEGER.
2. Which procedure header is written correctly?
A. PROCEDURE Greet(Name : STRING) ✓
B. PROCEDURE Greet(Name STRING)
The identifier and the data type must be separated by a colon. Without it the header is wrong.
3. Where is the parameter written when you define a procedure?
A. On the line after ENDPROCEDURE
B. In brackets straight after the procedure name ✓
The parameter goes in the brackets in the header, for example PROCEDURE Line(Size : INTEGER).
4. Which keyword ends the definition of a procedure?
A. ENDPROCEDURE ✓
B. ENDFUNCTION
A procedure starts with PROCEDURE and finishes with ENDPROCEDURE. ENDFUNCTION is for functions.
5. A procedure is defined as PROCEDURE Greet(Name : STRING). Which line inside the body outputs the value that was passed in?
A. OUTPUT "Hello Name"
B. OUTPUT "Hello ", Name ✓
Name without quotes uses the parameter's value. Inside quotes, Name is just the letters N-a-m-e.

Match the Pairs

PROCEDURE Line(Size : INTEGER) → Starts a procedure called Line with one parameter, Size, which must hold a whole number
PROCEDURE ShowName(Name : STRING) → Starts a procedure with one parameter, Name, that holds text
A parameter is used inside the procedure body like a variable, for example to output its value → OUTPUT Size
A procedure with a REAL parameter ends with ENDPROCEDURE after its body → PROCEDURE ShowPrice(Price : REAL) OUTPUT Price ENDPROCEDURE
PROCEDURE Line(Size INTEGER) → The colon is missing between the parameter name and its data type. It should be Size : INTEGER.
PROCEDURE Line(INTEGER : Size) → The identifier and data type are the wrong way round. The identifier comes first, then the colon, then the type: Size : INTEGER.

Key Term

PROCEDURE Line(Size : INTEGER)
Defines a procedure with one parameter. In the brackets after the name, write the parameter identifier, a colon, then its data type. Size is used inside the body.

Fill in the Blanks

1. PROCEDURE Line(Size : INTEGER) OUTPUT Size ENDPROCEDURE
Hint: Type the data type used for whole numbers.
2. PROCEDURE Greet(Name : STRING) OUTPUT "Hello ", Name ENDPROCEDURE
Hint: Type the keyword that starts a procedure definition.
3. PROCEDURE ShowPrice(Cost : REAL) OUTPUT Cost ENDPROCEDURE
Hint: Type the keyword that closes the procedure.
4. PROCEDURE Line(Size : INTEGER) OUTPUT Size ENDPROCEDURE
Hint: Type the parameter identifier so the body uses the value passed in.
5. PROCEDURE Greet(Name : STRING) OUTPUT Name ENDPROCEDURE
Hint: Type the symbol that separates the parameter identifier from its data type.

Spot the Error

Question 1
A PROCEDURE Line(Size : INTEGER)
B FOR Count ← 1 TO Length
C OUTPUT "*"
D NEXT Count
E ENDPROCEDURE
Line B — The parameter is called Size, so the loop must use Size. Length is not defined anywhere. It should be FOR Count ← 1 TO Size.
Question 2
A PROCEDURE Greet(Name : STRING)
B OUTPUT "Hello "
C OUTPUT Name
D ENDFUNCTION
Line D — A procedure must finish with ENDPROCEDURE. ENDFUNCTION is used to close a function.
Question 3
A PROCEDURE ShowTotal(Cost, REAL)
B OUTPUT "Total: ", Cost
C ENDPROCEDURE
Line A — A parameter is written as identifier, colon, data type. The comma should be a colon: ShowTotal(Cost : REAL).
Question 4
A PROCEDURE Box(Side : INTEGER)
B DECLARE Area : INTEGER
C Area ← Side * Side
D OUTPUT Size
E ENDPROCEDURE
Line D — The parameter is named Side, so Size does not exist in this procedure. The line should output the calculated value: OUTPUT Area.
Question 5
A PROCEDURE Stars(Num : INTEGER)
B FOR Count ← 1 TO Num
C OUTPUT "*
D NEXT Count
E ENDPROCEDURE
Line C — The string is missing its closing quotation mark. It should be OUTPUT "*".

Student with a class code? Join your class →