Assignment, Variables, Constants & Sequences
Inputs, Outputs & Type Conversion
Condition controlled Loops
Count Controlled loops
Nested Selection and Iteration
Subroutines 1 - Procedures
Subroutines 2 - Functions
Operators and Operations
Structured Programming
Validation and verification
Good notes will help you organise and process data and information
Here the main program (shown in the flowchart above on the left, beginning with the word “Start”) asks the user to input two numbers. It then asks them to select an option from a menu. If they enter the word “add”, it will run a subroutine called addNum (The smaller flowchart on the top right), if they enter anything else it will run the subtractNum subroutine (bottom right).
We can see the name of the subroutine has been defined along with the variables; num1 and num2. This means that the addNum subroutine is going to use the values of num1 and num2 and so has been passed these values.
This subroutine will add together the num1 and num2 variables and store these in a new variable called answer. It will then return the variable answer back to the main menu. It will then go back to the main menu, once the addNum subroutine has been completed, where it will be able to display the answer variable. If we had not returned the answer variable back to the main menu, it would not be able to display the answer in the output as the main program on its own has not defined the answer variable and it does not know what it is.
We have seen that we can use functions to return a single value to our calling routine. But it is also possible to return multiple values from our function, see psuedocode example below:
A Global Variable is a variable that is declared in the main program
A Local Variable is a variable that is declared and only used in a subroutine
Lets look at the learning outcomes and decide which one best describes our current level of understanding :
Tick the one you feel is closest to your level
Function tasks Click on the button below and complete as many exercises as you can
AQA Computer Science Tutor