← IGCSE Computer Science Paper 2

Procedure

A named subroutine that does a job, like outputting a line, but does not return a value. It is called as a full statement and can have parameters or none.

Understanding Procedure in IGCSE Computer Science Paper 2

What it does: The parameter Name is listed in the brackets of the procedure header, so the procedure can use the value given in the call. Procedures finish with ENDPROCEDURE. Functions end with ENDFUNCTION and use RETURN to send a value back. A procedure carries out a task but does not return a value. A function is the subroutine that returns a value. A procedure such as PROCEDURE ShowTitle() has no parameters. Parameters are optional. Subroutine names use Pascal case, such as ShowScore. Names cannot contain spaces.

Common mistakes: A procedure is called as a complete statement using CALL. It should be CALL ShowTitle(). This subroutine only outputs a line and returns no value, so it is a procedure. It must start with PROCEDURE to match ENDPROCEDURE.

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 389–398) and word search (Modules 379–398).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which statement describes a procedure?
A named subroutine that does a job and does not return a valueA named subroutine that always returns a value to the caller
Matches
x ← ShowLine()
↓
A procedure returns no value, so its result cannot be stored in a variable. It should be called with CALL ShowLine().
Applying
Meanings
Term
PROCEDURE
Meaning
A named subroutine that does a job, like outputting a line, but does not return a value. It is called as a full statement and can have parameters or none.
Practice
PROCEDURE ShowWelcome()
Testing
Gaps
ShowMenu()
Check Answer
Spots
3ENDPROCEDURE
4ShowTitle()

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

The 'Warthog' badge — Definition Digger, 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 statement describes a procedure?
A. A named subroutine that always returns a value to the caller
B. A named subroutine that does a job and does not return a value ✓
A procedure carries out a task but does not return a value. A function is the subroutine that returns a value.
2. Which is the correct way to call a procedure named ShowMenu?
A. total ← CALL ShowMenu()
B. CALL ShowMenu() ✓
A procedure is called as a complete statement on its own. Its result is not stored in a variable because it returns no value.
3. Which is a good job for a procedure?
A. Outputting a welcome message on the screen ✓
B. Working out the area of a rectangle and handing it back
Outputting a line is a job a procedure does. Handing a calculated value back is the work of a function.
4. True or false: a procedure must have at least one parameter.
A. False - a procedure can have parameters or none ✓
B. True - a procedure always needs a parameter
A procedure such as PROCEDURE ShowTitle() has no parameters. Parameters are optional.
5. Which header defines a procedure with one parameter?
A. PROCEDURE Greet(Name : STRING) ✓
B. PROCEDURE Greet(Name : STRING) RETURNS STRING
A procedure header has no RETURNS part because a procedure does not return a value. RETURNS belongs in a function header.

Match the Pairs

PROCEDURE ShowLine() OUTPUT "-----" ENDPROCEDURE → A procedure with no parameters that does a job (outputs a line) and does not return a value
CALL ShowLine() → A complete statement that runs the procedure ShowLine
A procedure can have a parameter so it can do its job with a value passed in → PROCEDURE Greet(Name : STRING)
A procedure does not return a value, so it ends with ENDPROCEDURE and has no RETURN → ENDPROCEDURE
x ← ShowLine() → A procedure returns no value, so its result cannot be stored in a variable. It should be called with CALL ShowLine().
PROCEDURE ShowLine() OUTPUT "-----" RETURN 5 ENDPROCEDURE → A procedure must not contain RETURN with a value because it does not return a value. Remove the RETURN line.

Key Term

PROCEDURE
A named subroutine that does a job, like outputting a line, but does not return a value. It is called as a full statement and can have parameters or none.

Fill in the Blanks

1. PROCEDURE ShowMenu() OUTPUT "Menu" ENDPROCEDURE
Hint: Type the keyword that starts the definition of a subroutine that does not return a value
2. PROCEDURE ShowMenu() OUTPUT "Menu" ENDPROCEDURE
Hint: Type the keyword that closes the procedure definition
3. CALL ShowMenu()
Hint: Type the keyword that runs a procedure as a complete statement
4. PROCEDURE Greet(Name : STRING) OUTPUT "Hello ", Name ENDPROCEDURE
Hint: Type the data type of the parameter, based on how it is used in the OUTPUT line
5. PROCEDURE Greet(Name : STRING) OUTPUT "Hi ", Name ENDPROCEDURE
Hint: Type the parameter name so the procedure outputs the value passed in

Spot the Error

Question 1
A PROCEDURE ShowTitle()
B OUTPUT "Quiz Time"
C ENDPROCEDURE
D ShowTitle()
Line D — A procedure is called as a complete statement using CALL. It should be CALL ShowTitle().
Question 2
A FUNCTION ShowLine()
B OUTPUT "----------"
C ENDPROCEDURE
D CALL ShowLine()
Line A — This subroutine only outputs a line and returns no value, so it is a procedure. It must start with PROCEDURE to match ENDPROCEDURE.
Question 3
A PROCEDURE Greet(Who : STRING)
B OUTPUT "Hello ", Who
C ENDFUNCTION
D CALL Greet("Sam")
Line C — A procedure must be closed with ENDPROCEDURE, not ENDFUNCTION.
Question 4
A PROCEDURE ShowSum(N : INTEGER)
B RETURN N + 10
C ENDPROCEDURE
D CALL ShowSum(5)
Line B — A procedure does not return a value, so it cannot use RETURN. It should do its job with OUTPUT N + 10.
Question 5
A PROCEDURE Show(N : INTEGER)
B OUTPUT "Number"
C OUTPUT M
D ENDPROCEDURE
E CALL Show(7)
Line C — The procedure only knows its parameter N. M has not been declared, so it should be OUTPUT N.

Student with a class code? Join your class →