2210/21/M/J/24 question 5: worked solution (May/June 2024, paper 21)

Show as plain text

Cambridge O Level Computer Science 2210 · 8.1 Programming concepts Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3. Q30 2210/21/M/J/24 original Q5 Structured · 5 marks 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 IDEA A CASE statement has one branch for each wanted value and OTHERWISE for everything else. TOTAL 5 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by ZAINEMATICS. Tap the picture to open it on YouTube.