9618/23/M/J/22 question 1: worked solution (May/June 2022, paper 23)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 11.2 Constructs Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 2 of 3. Q41 9618/23/M/J/22 original Q1 Structured · 8 marks Worked solution (a) Tick what each example uses: Pseudocode example Selection Iteration Assignment FOR Index ← 1 TO 3 ... NEXT Index ✓ ✓ OTHERWISE : OUTPUT "ERROR 1202" ✓ REPEAT UNTIL Index = 27 ✓ INPUT MyName ✓ IF Mark > 74 THEN Grade ← 'A' ENDIF ✓ ✓ FOR loop row: Iteration and Assignment [1] OTHERWISE row: Selection [1] REPEAT UNTIL row: Iteration [1] INPUT row: Assignment [1] IF row: Selection and Assignment [1] (b)(i) Work out each expression: Expression Evaluation AAA AND (Count > 99) FALSE AAA AND (NOT BBB) TRUE (Count <= 99) AND (AAA OR BBB) TRUE (BBB AND Count > 50) OR NOT AAA FALSE Any two rows correct [1] All four rows correct [1] (b)(ii) Any one of these: Use a Boolean as a flag to stop a loop when a value has been found [1] Or: when a variable can only be one of two values, such as Yes or No, or a light being on or off. KEY IDEA Spot selection, iteration and assignment in code, and evaluate Boolean expressions bracket by bracket. TOTAL 8 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Digify ID. Tap the picture to open it on YouTube.