Cambridge O Level Computer Science 2210 · 8.1 Programming concepts

Q27 · 2210/23/O/N/23 Q7

Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.

Q272210/23/O/N/23original Q7Structured · 4 marks
Question 7 from 2210/23/O/N/23

Worked solution

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]

KEY IDEALocal variables only work inside their subroutine; global variables work in the whole program.
TOTAL 4 marks

Official mark scheme

Mark scheme for 2210/23/O/N/23 question 7
VIDEO
▶ 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.