Question 6

OCR Computer Science June 2025 Algorithms and programming (H446-02)A level27 marks

On the specification

(a)
2.2 Problem solving and programming
(b)(i)
2.2 Problem solving and programming
(b)(ii)
2.2 Problem solving and programming
(b)(iii)
2.2 Problem solving and programming
(c)
2.2 Problem solving and programming
(d)
2.2 Problem solving and programming
Question text

6 A student is writing a program in a high-level programming language. (a) The student writes the program using an Integrated Development Environment (IDE). Complete the table by identifying and describing three features of an IDE that the student can use to debug their program. Debugging feature Description [6] (b) The program the student is developing includes both global and local variables. (i) Explain the difference between a global variable and a local variable. [2] (ii) Describe one drawback of using global variables in a program. [2] (iii) Describe one drawback of using local variables in a program. [2] (c) A variable can be passed as a parameter into a function by value or by reference. Describe what parameter passing by value means. [2] (d) An algorithm is needed to count how many times each of the numbers from 1 to 9 appear in an array called myArray. Another array called checked is used to store each number found in myArray and the number of times it appears. For example, the contents of myArray are: 73 6 7 5 3 2 3 6 Based on these contents in myArray, the contents in checked would be: 72 33 62 51 21 –1 0 –1 0 –1 0 –1 0 –1 indicates an unused space in the array as the numbers 1, 4, 8 and 9 have not been found. The student has written the following pseudocode for this program. The pseudocode contains several errors. 1 array myArray[9] 2 myArray = [7,3,6,7,5,3,2,3,6] 3 array checked[9,2] 4 checked = [[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0],[-1,0], [-1,0],[-1,0]] 5 numbersFound = 1 6 for x = 0 to myArray.length 7 found = false 8 for y = 0 to checked.length 9 if checked[y,0] == myArray[y] then 10 checked[y,1] = checked[y,1] + 1 11 found = true 12 endif 13 next y 14 if found == true then 15 checked[numbersFound,0] = myArray[x] 16 checked[numbersFound,1] = 0 17 numbersFound = numbersFound + 1 18 endif 19 next y Identify the line number of any four errors and write the corrected line for each error. Error 1 Line number Corrected line Error 2 Line number Corrected line Error 3 Line number Corrected line Error 4 Line number Corrected line [4]