Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3.
Input the number, then use CASE OF with a branch for 1, 2, 3 and 4 and OTHERWISE for anything else:
INPUT Number
CASE OF Number
1 : OUTPUT Number
2 : OUTPUT Number
3 : OUTPUT Number
4 : OUTPUT Number
OTHERWISE OUTPUT "ERROR"
ENDCASECorrect INPUT with a variable [1]
CASE OF ... ENDCASE structure present [1]
At least one correct branch [1]
All four branches (1 to 4) correct [1]
Correct use of OTHERWISE that outputs "ERROR" [1]
Outputting the values 1 to 4 directly (OUTPUT 1) also scores.
▶ Whole paper
Video solution of the whole paper · by ZAINEMATICS. 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.