A function is a named block of code that is called to perform a task and will return a value.
A return value is a value that is returned to the calling program.
Arguments are values provided to a subroutine at the time it is called.
Subroutine parameters are values used by the subroutine that are passed from the arguments when it is called.
Keywords
function
a subroutine that returns a value
return value
a value that is returned by a function
parameter
used in a subroutine to allow values to be passed into them
argument
values held in the brackets of a subroutine call, which are passed into a subroutine via the parameters
A common mistake
Mistake:When a function returns a value it can be used throughout the program that called it.
In fact:The return value needs to be stored if it is to be used later in the program that calls it. If it isn't stored, the value cannot be used again.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.Read the licence
Lesson 2 of 3 · GCSE level, ages 14 to 16
Procedures
By the end:I can create and call a procedure in a program.
As programs grow in complexity it becomes useful to structure them in a way that is more manageable for the programmer.
A structured approach to programming uses a module approach where a program is seperated into subroutines.
A program can be decomposed into smaller subroutines that are easier to solve indepedently.
The interface determines how data will be passed in and out of the subroutine.
Keywords
subroutine
a sequence of instructions with an identifiable name that performs a specific task
interface
describes how a subroutine will interact with the main program
identifer
the name that a programmer gives to a variable, constant, or subroutine
parameters
used in a subroutine to allow values to be passed into them
A common mistake
Mistake:A program must run line by line from top to bottom.
In fact:A subrotuine is an 'out of line' block of code, which is typcially written at the top of a program and then called upon within the main program.
Check what you learned
From Oak National Academy's exit quiz. Choose every answer that is right.
A computing lesson by Oak National Academy licensed under the Open Government Licence (OGL) v3.0.Read the licence
The wording comes from each publisher. The layout and the links to your syllabus are ours.