Subroutines: Procedures and Functions
Aligned to the AQA 8525 specification
- Topic
- Programming
- Level
- Intermediate
- Reading time
- 9 min
- Published
- 8 June 2026
- Updated
- 1 July 2026
On this page
Key takeaways
- A subroutine is a named, self-contained block of code that performs a specific task and can be called from anywhere, after which control returns to the point of the call.
- A procedure performs an action and returns no value, while a function calculates a result and returns it to the caller using RETURN; every function must have at least one RETURN statement.
- A parameter is a variable listed in the subroutine's definition; an argument is the actual value supplied when it is called, and arguments are matched to parameters by position.
- A local variable is declared inside a subroutine and exists only while it executes; a global variable is declared outside all subroutines and accessible anywhere. Locals are preferred as they avoid name conflicts.
- Structured programming organises a program as a hierarchy of subroutines, making it easier to read, test, maintain and reuse, and allowing parallel development by multiple programmers.
How much of this have you taken in?
Quiz yourself on this section, free, no card needed.
Key terms
- Subroutine
- A named, self-contained block of code that performs a specific task and can be called from anywhere in a program.
- Procedure
- A subroutine that performs an action and does not return a value to the caller.
- Function
- A subroutine that calculates a result and sends it back to the caller using a RETURN statement.
- Parameter
- A variable listed in a subroutine's definition that receives a value passed in by the caller.
- Argument
- The actual value supplied when a subroutine is called, matched to a parameter by position.
- Local variable
- A variable declared inside a subroutine that exists only while that subroutine is executing and cannot be accessed from outside it.
- Global variable
- A variable declared outside all subroutines that can be accessed from anywhere in the program.
- Scope
- The part of a program where a variable can be read or modified.
- Structured programming
- Organising a program as a hierarchy of subroutines, each with a single, clearly defined responsibility.
Frequently asked questions
A procedure performs an action, such as displaying output, and does not return a value to the caller. A function calculates a result and sends it back to the caller using RETURN, so the caller can use that value in an expression, store it, or pass it on.
A parameter is a variable listed in the subroutine's definition, while an argument is the actual value supplied when the subroutine is called. Parameters receive their values from arguments at the moment of the call, matched by position.
Local variables can only be modified by their owning subroutine, making bugs easier to trace and the subroutine self-contained and reusable. They also avoid name conflicts, since two subroutines can use the same identifier as separate local variables without clashing.
Generate revision on any topic you study
Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.
Lessons on anything
Structured, level-matched lessons on any topic you study
Practice quizzes
Find out what you actually know before the exam does
Flashcard sets
Lock in key concepts with instant revision cards
Ask Aica
Stuck on something? Get a clear explanation, any time
Arrays and Records
Robust and Secure Programming
Related lessons
9 min
8 min
8 min