Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3.
Work through the CASE clauses in order.
| Answer | |
|---|---|
| Level when ThisValue is 40 | "Medium" |
| Check when ThisValue is 36 | 12 |
| Level when ThisValue is 18 | "Low" |
| Elements of Data that may be incremented | 11 |
40 is in 30 TO 40, so "Medium" [1]
36 / 3 = 12 [1]
18 is less than 30 (the first clause), so "Low" [1]
Values 30 to 40 give 40 - 30 + 1 = 11 elements [1]
Write: the assignment Level ← "Very Low" is never performed [1]
Write: because the clauses are checked in order [1]
Write: any value below 30 matches the first clause, so the < 20 clause is never reached [1]
Write: every possible value is already handled by the other four clauses, so there is no value left for OTHERWISE [1]
ThisValue: INTEGER [1]
Check: REAL (a division can give a fraction) [1]
Level: STRING [1]
▶ Starts at Q1 (0:23)
Starts at Q1 (0:23) · by Pseudocode Pro. 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.