Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 3 of 3.
Write any three of these:
Library routines are tried and tested, so they are free from errors. [1]
They are readily available, which speeds up development. [1]
They are updated automatically when improved, so no maintenance is needed. [1]
The algorithm will follow the international standard. (Also accepted for the third mark.)
Write any two of these:
The subroutine does one specific task. [1]
The code is used in several places so it is written once. [1]
Testing, debugging or maintenance is easier. (Also accepted.)
| Term | Description |
|---|---|
| Pass2 | the name of the function |
| Count | the parameter passed to the function |
| BOOLEAN | the data type of the value the function returns |
Count described as the parameter [1]
BOOLEAN described as the return type [1]
LENGTH of "2.5" is 3. MONTH(DoB) is 6, and 6 > 4 is TRUE. The 2nd character of the address is "5", so 15 + 5 = 20.
| Expression | Evaluates to |
|---|---|
| LENGTH(NUM_TO_STR(Multiplier)) | 3 |
| MONTH(DoB) > 4 | TRUE |
| 15 + STR_TO_NUM(MID(AddressLine[1], 2, 1)) | 20 |
3 [1]
TRUE [1]
20 [1]
▶ Topic lesson
A lesson on this topic · 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.