Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3.
Match each variable to the kind of value stored:
| Assignment statement | Data type |
|---|---|
| A ← LEFT(MyName, 1) | CHAR (or STRING) |
| B ← Total * 2 | INTEGER (or REAL) |
| C ← INT(ItemCost) / 3 | REAL |
| D ← "Odd OR Even" | STRING |
A: CHAR or STRING [1]
B: INTEGER or REAL [1]
C: REAL (division) [1]
D: STRING [1]
Use Sorted = False, Tries = 9, ID = "ZGAC001":
| Expression | Evaluates to |
|---|---|
| Tries < 10 AND NOT Sorted | TRUE |
| Tries MOD 4 | 1 |
| TO_LOWER(MID(ID, 3, 1)) | "a" |
| LENGTH(ID & "xx") >= Tries | TRUE |
9 < 10 is TRUE and NOT FALSE is TRUE, so TRUE [1]
9 ÷ 4 = 2 remainder 1 [1]
The 3rd character of ID is "A", in lower case "a" [1]
ID & "xx" has 9 characters and 9 >= 9, so TRUE [1]
Write: the names do not show what each variable is used for (they are not meaningful). [1]
Write: the program is harder to understand, debug or maintain. [1]
Write any one of: indentation or white space; capital letters for keywords; comments; modular programming; local variables. [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.