9618/23/M/J/23 question 1: worked solution (May/June 2023, paper 23)

Show as plain text

Cambridge AS Level Computer Science 9618 · 10.2 Arrays Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 2 of 4. Q23 9618/23/M/J/23 original Q1 Structured · 10 marks Worked solution (a) Read the declaration and the loop: Answer The dimension of the array 2 The name of the variable used as an array index PCount The number of elements in the array 100 Dimension is 2 because there are two index ranges [1] Index variable is PCount [1] 2 × 50 = 100 elements [1] (b) Error: the second dimension of the array is declared from 1 to 50, but the loop runs from 0 to 49 [1] Line number: 10 (also accepted: 100, 101 or 102) [1] (c) Write: INTEGER [1] (d) Decide what each statement does: Pseudocode statement Input Process Output INPUT MyChoice ✓ OUTPUT FirstName & LastName ✓ ✓ WRITEFILE YourFile, TextLine ✓ READFILE MyFile, TextLine ✓ Result ← SQRT(NextNum) ✓ OUTPUT FirstName & LastName: Process and Output ticked (joining the strings is a process) [1] WRITEFILE: Output ticked [1] READFILE: Input ticked [1] Result ← SQRT(NextNum): Process ticked [1] KEY IDEA Count array elements by multiplying the ranges, keep loop limits inside the declared bounds, and know input, process and output. TOTAL 10 marks Official mark scheme VIDEO ▶ Starts at Q1 (1:30) Starts at Q1 (1:30) · by Zafar Ali Khan (ZAK). Tap the picture to open it on YouTube.