9618/23/O/N/24 question 1: worked solution (October/November 2024, paper 23)

Show as plain text

Cambridge AS Level Computer Science 9618 · 11.1 Programming Basics Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 1 of 3. Q29 9618/23/O/N/24 original Q1 Structured · 10 marks Worked solution (a) Decide which constructs each example uses: Pseudocode example Selection Iteration Subroutine FOR ... IF ... NEXT ✓ ✓ CASE OF Compound(3) ✓ ✓ REPEAT UNTIL AllDone() = TRUE ✓ ✓ WHILE Result [3] <> FALSE ✓ FOR loop with IF row correct (selection and iteration) [1] CASE row correct (selection and subroutine, because Compound(3) is a function call) [1] REPEAT row correct (iteration and subroutine, because AllDone() is a function call) [1] WHILE row correct (iteration only) [1] (b) Look at the example value: Variable Example data value Data type Available TRUE BOOLEAN Received "18/04/2021" STRING Index 100 INTEGER Available is BOOLEAN [1] Received is STRING (it is in quote marks) [1] Index is INTEGER [1] (c) Use Available = TRUE and Index = 100: Expression Evaluates to Available AND NOT(Index > 100) TRUE Index MOD 30 10 NUM_TO_STR(Index + "33") ERROR Index > 100 is FALSE, NOT makes it TRUE, TRUE AND TRUE gives TRUE [1] 100 ÷ 30 = 3 remainder 10, so 10 [1] Index + "33" adds a number to a string, which is not allowed, so ERROR [1] KEY IDEA Check the data type of each value before using it in an expression. TOTAL 10 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.