Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.
Describe two differences, each with a point about local and the matching point about global:
Difference 1: local variables have a scope of only the block of code or subroutine (procedure or function) they are declared in [1]
...whereas global variables have a scope of the whole program [1]
Difference 2: the value of a local variable cannot be changed elsewhere in the program [1]
...whereas the value of a global variable can be changed anywhere in the program [1]
▶ Whole paper
Video solution of the whole paper · by O/Alevel CS by Wasiq. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.