9618/23/O/N/22 question 3: worked solution (October/November 2022, paper 23)

Show as plain text

Cambridge AS Level Computer Science 9618 · 9.2 Algorithms Worked solution from the Algorithm Design and Problem-solving Paper 2 Problem-solving and Programming booklet, Part 2 of 2. Q26 9618/23/O/N/22 original Q3 Structured · 5 marks 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 IDEA Set the totals to zero, loop on the input, add to the right total, and output after the loop. TOTAL 5 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.