AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Students should be able to describe how data is passed out of a subroutine…
Full specification wording
Structured programming and subroutines (procedures and functions): Students should be able to describe how data is passed out of a subroutine using return values.
A subroutine that produces a result hands it back to the calling code through a return value.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 4 of 9
Study notes
From the checked teaching notes for this specification point.
The idea
A subroutine that produces a result hands it back to the calling code through a return value. Inside the subroutine, a return statement ends execution and supplies the value; the call site captures it, for example total = addScores(4, 7), where addScores returns 11 and the variable total receives it. The value travels out only through that return, not through the subroutine's local variables, which disappear when it finishes. A function is expected to return a value, whereas a procedure typically performs an action without returning one. The returned value can be stored, printed, tested in a condition or passed into another subroutine. Describe the route: the subroutine computes a result, executes return with that value, control passes back to the caller, and the caller assigns or uses the returned data.
What earns the marks
- A return value is the data a subroutine sends back to the code that called it.
- A return statement ends the subroutine and supplies the value to the caller.
- The calling code captures the returned value, for example by assigning it to a variable.
- Functions normally return a value; procedures normally do not.
- The returned value can then be stored, displayed, tested or passed on.
- Local variables inside the subroutine are not the mechanism for passing data out.
Common mistakes and how to put them right
Thinking a subroutine passes data out by leaving its local variables visible to the caller.
Put it right: The value leaves only through the return statement.
Confusing parameters (data passed in) with return values (data passed out).
Put it right: Parameters go in, return values come out.
Assuming every subroutine returns a value.
Put it right: Procedures typically return nothing while functions return a value.
Believing the return value appears automatically without the caller using it.
Put it right: The caller must capture or use the returned value.
Exam tips
- Name the three stages: subroutine computes, return supplies the value, caller captures it.
- Use a short code example such as result = double(5) to show the value leaving and being stored.
- Contrast parameters going in with return values coming out to show you understand direction.
Try the lesson
The start of the Structured programming and subroutines (procedures and functions): Students should be able to describe how data is passed out of a subroutine using return values. lesson, made from checked teaching notes for this specification point.
Have a go first
A function called doubleIt takes a number and produces twice that number. How does the result get back to the line of code that called the function?
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 Structured programming and subroutines (procedures and functions): Students should be able to describe how data is passed out of a subroutine using return values.
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