AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Programming concepts: subroutine (procedure/function).
A subroutine is a named block of code that performs a specific task and can be called (invoked) from elsewhere in a program, so the same logic is written once and reused.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 7 of 23
Study notes
From the checked teaching notes for this specification point.
The idea
A subroutine is a named block of code that performs a specific task and can be called (invoked) from elsewhere in a program, so the same logic is written once and reused. AQA GCSE Computer Science distinguishes two kinds. A procedure performs an action and does not return a value to the caller. A function performs a task and returns a value, which the calling code can then use in an expression or assignment. Subroutines may take parameters (inputs passed in) and may use local variables that exist only while the subroutine runs. Calling a subroutine transfers control to it; when it finishes, control returns to the point after the call. Benefits include reuse, easier testing and maintenance, and reduced duplication. Exam items typically ask you to classify a given subroutine as a procedure or function, or to state what a call returns, so look for whether a value is returned.
What earns the marks
- A subroutine is a named, reusable block of code that performs a specific task and is called from elsewhere.
- A procedure performs an action but does not return a value to the caller.
- A function performs a task and returns a value that the calling code can use.
- Subroutines can accept parameters as inputs and may use local variables.
- Calling a subroutine transfers control to it and returns to the point after the call when it finishes.
- Reuse of subroutines reduces duplication and makes programs easier to test and maintain.
Common mistakes and how to put them right
Treating procedure and function as identical.
Put it right: A function returns a value whereas a procedure does not.
Assuming a subroutine runs automatically.
Put it right: It runs only when called.
Confusing parameters with return values.
Put it right: Parameters are inputs passed in, while a return value is output sent back.
Thinking local variables persist after the subroutine ends.
Put it right: They exist only during the call.
Exam tips
- To classify a subroutine, check whether it returns a value: if it does, it is a function; if not, a procedure.
- Look for the return statement or an assignment that captures the result to confirm a function.
- Remember a subroutine executes only when it is called, not when it is defined.
- Distinguish inputs (parameters) from outputs (return value) when reading a fragment.
Try the lesson
The start of the Programming concepts: subroutine (procedure/function). lesson, made from checked teaching notes for this specification point.
Have a go first
A programmer writes a block of code that draws a triangle on screen, and calls it by name three times in a drawing program. What is this named block of code called?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Programming concepts: subroutine (procedure/function).
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge