Cambridge AS Level Computer Science 9618 · 9.2 Algorithms

Q26 · 9618/23/O/N/22 Q3

Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2.

Q269618/23/O/N/22original Q3Structured · 5 marks
Question 3 from 9618/23/O/N/22

Worked solution

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]

KEY IDEASet the totals to zero, loop on the input, add to the right total, and output after the loop.
TOTAL 5 marks

Official mark scheme

Mark scheme for 9618/23/O/N/22 question 3
VIDEO
▶ 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.