Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Follow the flowchart. Numbers below 100 or above 999 skip straight back to the start of the loop. Counter goes up each time round and the loop stops when Counter is more than 7.
| Counter | Number | Hundreds | Temp | Tens | Units | OUTPUT |
|---|---|---|---|---|---|---|
| 0 | ||||||
| 1 | 97 | |||||
| 2 | 876 | 8 | 76 | 7 | 6 | Hundreds: 8 Tens: 7 Units: 6 |
| 3 | 4320 | |||||
| 4 | 606 | 6 | 6 | 0 | 6 | Hundreds: 6 Tens: 0 Units: 6 |
| 5 | 9875 | |||||
| 6 | 42 | |||||
| 7 | 124 | 1 | 24 | 2 | 4 | Hundreds: 1 Tens: 2 Units: 4 |
| 8 |
Counter and Number columns correct [1]
Hundreds column correct [1]
Temp and Tens columns correct [1]
Units column correct [1]
OUTPUT column correct [1]
▶ Topic lesson
A lesson on this topic · by Mr Bulmer's Learning Zone. 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.