9618/23/M/J/24 question 1: worked solution (May/June 2024, paper 23)
Show as plain textHide plain text
Cambridge AS Level Computer Science 9618 · 11.3 Structured Programming Worked solution from the Programming Paper 2 Problem-solving and Programming booklet, Part 3 of 3. Q86 9618/23/M/J/24 original Q1 Structured · 9 marks Worked solution (a)(i) Write any two of these benefits: The code can be called whenever it is needed [1] A later change to the algorithm is made once only , so the program is easier to maintain [1] Less code, with no duplication (or the algorithm is designed, coded and tested once). Only two of these points can score. (a)(ii) Say how the repeated code is turned into a module: Create a module (function, procedure or subroutine) from the algorithm code [1] Replace the old code in every place with a call to the module [1] Pass the data in as parameters (or use global variables) and return the result (or assign it to a global variable or a BYREF parameter). Create local variables if needed. Any one of these points earns the last mark [1] (b) Choose the built-in function or operator from the insert that gives each value: Pseudocode expression Evaluates to MID("Random", 2, 3) "and" 5 + DAY(10/11/2023) 15 IS_NUM("45000") TRUE (20 MOD 3) + 1 3 MID correct [1] DAY correct [1] IS_NUM correct [1] MOD correct [1] KEY IDEA Put repeated code in one module and call it, passing data in and returning the result. TOTAL 9 marks Official mark scheme VIDEO ▶ Starts at Q1 (0:27) Starts at Q1 (0:27) · by Pseudocode Pro. Tap the picture to open it on YouTube.