9618/22/M/J/24 question 5: worked solution (May/June 2024, paper 22)

Show as plain text

Cambridge AS Level Computer Science 9618 · 12.3 Program Testing and Maintenance Worked solution from the Software Development Paper 2 Problem-solving and Programming booklet, Part 3 of 3. Q49 9618/22/M/J/24 original Q5 Structured · 6 marks Worked solution (a)(i) Find two syntax errors and one other error: Syntax error 1: NEXT Index is wrong in a WHILE loop; it should be ENDWHILE [1] Syntax error 2: & is used to join an integer (Index) to a string in OUTPUT, so Index must be converted or separated with a comma [1] Other error: the array is accessed outside its range , because Data [0] is used when the first element is index 1 [1] (a)(ii) Statement: OTHERWISE : OUTPUT "Alarm 1201" [1] Explanation: Index MOD 2 can only give 0 or 1 , so this branch can never run [1] (b) The program compiles, so it has no syntax errors, but it stops responding when it runs. Write: a run-time error [1] KEY IDEA MOD 2 only gives 0 or 1, and a CASE branch that can never be reached is not needed. TOTAL 6 marks Official mark scheme VIDEO ▶ Starts at Q5 (38:09) Starts at Q5 (38:09) · by Pseudocode Pro. Tap the picture to open it on YouTube.