2210/21/M/J/24 question 2: worked solution (May/June 2024, paper 21)
Show as plain textHide plain text
Cambridge O Level Computer Science 2210 · 8.1 Programming concepts Worked solution from the Programming Paper 2 Algorithms, Programming and Logic booklet, Part 1 of 3. Q28 2210/21/M/J/24 original Q2 Structured · 9 marks Worked solution (a) Match each description to its concept: Description Programming concept a subroutine that may not return a value procedure a value that is declared and used within a specific procedure local variable a value that a procedure expects you to supply when it is called parameter a subroutine that will always return a value function a subroutine that may not return a value → procedure [1] declared and used within a specific procedure → local variable [1] a value a procedure expects when called → parameter [1] a subroutine that will always return a value → function [1] global variable is not used. (b) Use the keyword CALL, then the procedure name with the two values in brackets: CALL Average(25, 50) Keyword CALL [1] Procedure name with the correct parameters, Average(25, 50) [1] (c) Write any three points: Procedures and functions divide the program into smaller manageable parts , so it is easier to read, understand and debug [1] They can be re-used in the program or in other programs, and run from a single line [1] They reduce repeated code , so there is less to change when the program is updated [1] Also accepted: meaningful names act as documentation (abstraction). KEY IDEA A procedure may not return a value, a function always does; parameters carry values in, local variables stay inside one subroutine. TOTAL 9 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by ZAINEMATICS. Tap the picture to open it on YouTube.