Global and local variables.
2.2.1 Programming Techniques
Programming Techniques — Note 3 of 6
Candidates need to understand the difference, benefits and drawbacks of global and local variables. Candidates must be able to recognise where each is used and its impact on a program, for example the amount of memory used, and change a program from one to the other.
A variable's scope is the part of the program where it can be used. Global variables can be used anywhere; local variables only exist inside the subroutine where they are declared. Choosing the correct scope makes programs more reliable and easier to maintain.
Declared in the main program and accessible from anywhere in the program, including inside subroutines. In OCR pseudocode: global userid = 123.
Declared inside a subroutine; it only exists while the subroutine runs and can only be accessed within it.