9618/22/M/J/25 question 4: worked solution (May/June 2025, paper 22)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 10.2 Arrays Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4. Q36 9618/22/M/J/25 original Q4 Structured · 6 marks Worked solution Draw the flowchart in this order. The first loop reads the values and the second loop outputs them backwards. START → box: SET Count TO 1 → decision: IS Count = 101 ? Index (Count) set to 1 (or 0) before the first loop [1] Loop that runs 100 times (decision Count = 101, with NO going round the loop) [1] On NO: parallelogram INPUT Value [1] Then box SET Number[Count] TO Value, then box Increment Count, then back to the decision [1] On YES: box SET Count TO 100, then decision IS Count = 0 ? so the output loop starts at the last element [1] On NO: parallelogram OUTPUT Number[Count], then box Decrement Count, then back to the decision; on YES go to END, so every element is output once in reverse order [1] KEY IDEA Use one counter loop going up to store the values and a second loop going down to output them in reverse. TOTAL 6 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Awab Aqib. Tap the picture to open it on YouTube.