Break a program into procedures
Group a reusable task in a procedure and pass values through parameters where needed.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. It covers section 8.1 (Programming concepts) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding.
Before you begin
- Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
What is a parameter for?
What you will learn
- Distinguish a procedure from a function
- Define and call procedures
- Use parameters to supply information
A procedure performs a named task
A procedure is defined with PROCEDURE and closed with ENDPROCEDURE. Call it with CALL when the program needs that task.
A procedure may have no parameters or may accept up to three. Parameters let the same routine work with different supplied values rather than fixed data.
A function returns one value
A function is defined with FUNCTION and a RETURNS data type. RETURN sends one value back; use the function call inside an expression, without CALL.
Use a procedure for an action such as displaying a menu, and a function when the caller needs a calculated value such as a total or decision.
Pause and explain
When should a calculation be a function rather than a procedure?
Worked example
Define a procedure that displays a greeting for a supplied name and show one call.
Show the worked solution
- Declare a STRING parameter called LearnerName.
- Output a greeting using the parameter.
- Call the procedure with a name value.
Answer PROCEDURE Greet(LearnerName : STRING) OUTPUT "Hello, ", LearnerName ENDPROCEDURE CALL Greet("Mai")
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A procedure named ShowLine should output a row of dashes. Show a definition and call without parameters.
Give me a hint
The caller does not need to supply a size in this example.
Compare my reasoning
- Define PROCEDURE ShowLine.
- Output a fixed row inside it.
- Close the procedure and use CALL ShowLine.
PROCEDURE ShowLine; OUTPUT "----------"; ENDPROCEDURE; CALL ShowLine.
Look for these in your work
- Procedure form
- Action inside
- CALL used
A procedure prints a line whose size is supplied by the caller. What parameter and call could it use?
Give me a hint
The size is a whole number.
Compare my reasoning
- Declare Size : INTEGER as a parameter.
- Use Size to control output.
- Call the procedure with a numeric argument such as 12.
PROCEDURE DrawLine(Size : INTEGER) ...; CALL DrawLine(12).
Look for these in your work
- Parameter type
- Argument supplied
A routine calculates and returns a shipping cost. Explain why it is a function and how the caller uses it.
Give me a hint
The caller needs the calculated number.
Compare my reasoning
- Define a FUNCTION with a numeric RETURNS type.
- Return the calculated cost.
- Use the function call in an assignment or output expression.
Use a function because the caller needs a value, for example Cost ← ShippingCost(Weight).
Look for these in your work
- Function choice
- Returned result used
Common mistakes
- Calling a function with CALL instead of using its returned value
- Forgetting to pass a required argument
- Writing a procedure that only works for one hard-coded value
What can you explain now?
Which keyword calls a procedure?
Compare with the explanation
CALL
A procedure is invoked with CALL.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
What is the key difference between a procedure and a function?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.