Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2.
Describe the steps in order, in words:
Declare two variables for the two sums (real numbers) and set both to zero. [1]
Prompt for and input a number. [1]
If the number is greater than zero, add it to the positive sum. If it is less than zero, add it to the negative sum. [1]
Repeat from the input step if the number is not zero. [1]
When zero is input and the loop ends, output the positive sum and the negative sum. [1]
▶ Whole paper
Video solution of the whole paper · by Zafar Ali Khan (ZAK). 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.