Cambridge O Level Computer Science 2210 · 8.1 Programming concepts

Q30 · 2210/21/M/J/24 Q5

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

Q302210/21/M/J/24original Q5Structured · 5 marks
Question 5 from 2210/21/M/J/24

Worked solution

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"
ENDCASE

Correct 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.

KEY IDEAA CASE statement has one branch for each wanted value and OTHERWISE for everything else.
TOTAL 5 marks

Official mark scheme

Mark scheme for 2210/21/M/J/24 question 5
VIDEO
▶ 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.