Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.
Follow the flowchart one box at a time. Total and Count are set to 0 at the start of every group. A value of 0 ends a group: work out the average, output the total and average, then start again. A value of -1 stops the algorithm.
| Value | Average | Total | Count | OUTPUT |
|---|---|---|---|---|
| 0 | 0 | |||
| 25 | 25 | 1 | ||
| 35 | 60 | 2 | ||
| 3 | 63 | 3 | ||
| 0 | 21 | Total is 63 | ||
| Average is 21 | ||||
| 0 | 0 | |||
| 57 | 57 | 1 | ||
| 20 | 77 | 2 | ||
| 25 | 102 | 3 | ||
| 18 | 120 | 4 | ||
| 0 | 30 | Total is 120 | ||
| Average is 30 | ||||
| 0 | 0 | |||
| -1 |
Value column correct [1]
Average column correct [1]
Total column correct [1]
Count column correct [1]
OUTPUT column correct [1]
Write any two of these:
The algorithm adds together a group (batch) of numbers and finds their average [1]
The total and average are output when a 0 is entered, which ends the group [1]
A new group is started after each 0, so the algorithm works on several groups until -1 is entered (this point also scores)
▶ Whole paper
Video solution of the whole paper · by Paper solver.. 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.