4.1.1.10 Subroutines (Procedures/ Functions)
To meet this objective, you should be able to
Be familiar with subroutines and their uses.
Know that a subroutine is a named ‘out of line’ block of code that may be executed (called) by simply writing its name in a program statement.
Be able to explain the advantages of using subroutines in programs.
An easy way to tell the difference between a Procedure and a Function is to look at the names:
Functions are fun: if you would call them, they would return a value'
Procedures aren't fun: if you call them they don't return any value.
Parameter or argument?
Parameter or argument?
A parameter is the variable listed inside the parentheses in the function definition. (See line 1)
An argument is the value that are sent to the function when it is called. (See line 5)
Check out the code