Skip to content

Programming techniques: OCR A‑Level Computer Science questions

Every OCR A-Level Computer Science exam question on 2.2.1 Programming techniques, 2021–2025, with its mark scheme and examiner’s report.

Find questions593
Calculations

593 questions

  1. Q1(c)(i)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 1(c)(i): Identify which of the two functions is recursive and give all of the line numbers where recursive calls are made. Recursive function name Recursive call line nu
  2. Q1(c)(ii)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 1(c)(ii): Identify the type of iteration used in the function partition(). [1]
  3. Q3(d)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 3(d): A program is designed to reverse a set of data using the stack. The main program takes 10 characters separately as input from the user and uses the function pus
  4. Q6(a)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 6(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
  5. Q6(b)(i)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 6(b)(i): Explain the difference between a global variable and a local variable. [2]
  6. Q6(b)(ii)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 6(b)(ii): Describe one drawback of using global variables in a program. [2]
  7. Q6(b)(iii)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 6(b)(iii): Describe one drawback of using local variables in a program. [2]
  8. Q6(c)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 6(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]
  9. Q6(d)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 6(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
  10. Q8(b)(i)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 8(b)(i): The method getNextNode() returns the attribute nextNode. Write the method getNextNode() using pseudocode or program code. [2]
  11. Q8(b)(ii)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 8(b)(ii): The method setValue() takes an integer as a parameter and assigns this to the attribute value. Write the method setValue() using pseudocode or program code. [3]
  12. Q8(c)(i)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 8(c)(i): Write the constructor method using pseudocode or program code. [2] The class design for node and linkedList are shown again here for your reference. class: node
  13. Q8(d)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 8(d): The method insertNode() will insert a new node into the linked list. The method accepts an integer as a parameter, creates a new node with that data and inserts
  14. Q8(g)

    June 2025 · Paper 2

    The whole paper ↗
    June 2025 Paper 2, question 8(g): A linked list data structure is designed using object-oriented programming. The design includes two classes called node and linkedList. (g)* This program uses c
  15. Q3(b)

    June 2025 · AS Paper 1

    The whole paper ↗
    June 2025 AS Paper 1, question 3(b): When the data is collated, the answers for each question are stored in separate 2-dimensional arrays. Question 1 is stored in an array called resultsQ1. Each pe
  16. Q6(b)(ii)

    June 2025 · AS Paper 1

    The whole paper ↗
    June 2025 AS Paper 1, question 6(b)(ii): Write the function findAverage that will accept the array steps as a parameter and then return the average number of steps. You should write your answer using p
  17. Q2(b)(ii)

    June 2025 · AS Paper 2

    The whole paper ↗
    June 2025 AS Paper 2, question 2(b)(ii): Rewrite the code in lines 02 to 07 to use a for loop instead of a while loop. Write your answer using pseudocode or program code. [2]
  18. Q2(b)(iii)

    June 2025 · AS Paper 2

    The whole paper ↗
    June 2025 AS Paper 2, question 2(b)(iii): State one reason why the array should be passed by reference and not by value. [1]
  19. Q2(c)

    June 2025 · AS Paper 2

    The whole paper ↗
    June 2025 AS Paper 2, question 2(c): When a user collects an item, the name and type are added to the array p1Items. At the end of the game, the name of each item collected is output. Write an algo
  20. Q5(a)

    June 2025 · AS Paper 2

    The whole paper ↗
    June 2025 AS Paper 2, question 5(a): Identify two subroutines that are called in the pseudocode algorithm. 1 2 [2]
All 118 questions on Programming techniques, as a list
  1. June 2025, Paper 2, Q1(c)(i) (2 marks): Identify which of the two functions is recursive and give all of the line numbers where recursive calls are made. Recursive function name Recursive call line nu
  2. June 2025, Paper 2, Q1(c)(ii) (1 mark): Identify the type of iteration used in the function partition(). [1]
  3. June 2025, Paper 2, Q3(d) (5 marks): A program is designed to reverse a set of data using the stack. The main program takes 10 characters separately as input from the user and uses the function pus
  4. June 2025, Paper 2, Q6(a) (6 marks): The student writes the program using an Integrated Development Environment (IDE). Complete the table by identifying and describing three features of an IDE that
  5. June 2025, Paper 2, Q6(b)(i) (2 marks): Explain the difference between a global variable and a local variable. [2]
  6. June 2025, Paper 2, Q6(b)(ii) (2 marks): Describe one drawback of using global variables in a program. [2]
  7. June 2025, Paper 2, Q6(b)(iii) (2 marks): Describe one drawback of using local variables in a program. [2]
  8. June 2025, Paper 2, Q6(c) (2 marks): A variable can be passed as a parameter into a function by value or by reference. Describe what parameter passing by value means. [2]
  9. June 2025, Paper 2, Q6(d) (4 marks): 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
  10. June 2025, Paper 2, Q8(b)(i) (2 marks): The method getNextNode() returns the attribute nextNode. Write the method getNextNode() using pseudocode or program code. [2]
  11. June 2025, Paper 2, Q8(b)(ii) (3 marks): The method setValue() takes an integer as a parameter and assigns this to the attribute value. Write the method setValue() using pseudocode or program code. [3]
  12. June 2025, Paper 2, Q8(c)(i) (2 marks): Write the constructor method using pseudocode or program code. [2] The class design for node and linkedList are shown again here for your reference. class: node
  13. June 2025, Paper 2, Q8(d) (5 marks): The method insertNode() will insert a new node into the linked list. The method accepts an integer as a parameter, creates a new node with that data and inserts
  14. June 2025, Paper 2, Q8(g) (12 marks): A linked list data structure is designed using object-oriented programming. The design includes two classes called node and linkedList. (g)* This program uses c
  15. June 2025, AS Paper 1, Q3(b) (7 marks): When the data is collated, the answers for each question are stored in separate 2-dimensional arrays. Question 1 is stored in an array called resultsQ1. Each pe
  16. June 2025, AS Paper 1, Q6(b)(ii) (5 marks): Write the function findAverage that will accept the array steps as a parameter and then return the average number of steps. You should write your answer using p
  17. June 2025, AS Paper 2, Q2(b)(ii) (2 marks): Rewrite the code in lines 02 to 07 to use a for loop instead of a while loop. Write your answer using pseudocode or program code. [2]
  18. June 2025, AS Paper 2, Q2(b)(iii) (1 mark): State one reason why the array should be passed by reference and not by value. [1]
  19. June 2025, AS Paper 2, Q2(c) (6 marks): When a user collects an item, the name and type are added to the array p1Items. At the end of the game, the name of each item collected is output. Write an algo
  20. June 2025, AS Paper 2, Q5(a) (2 marks): Identify two subroutines that are called in the pseudocode algorithm. 1 2 [2]
  21. June 2025, AS Paper 2, Q5(b) (2 marks): Name the programming constructs that start on line 01 and line 08 in the pseudocode algorithm. 01 08 [2]
  22. June 2025, AS Paper 2, Q5(c) (1 mark): State the purpose of line 06. [1]
  23. June 2025, AS Paper 2, Q7 (8 marks): Write an algorithm, using program code or pseudocode to: • take a user’s date of birth as a string input in the format DD/MM/YYYY • take a year as input from th
  24. June 2024, Paper 2, Q1(a)(i) (2 marks): Describe what is meant by a variable. [2]
  25. June 2024, Paper 2, Q1(a)(ii) (1 mark): Give the identifiers of all the variables used in this program. [1]
  26. June 2024, Paper 2, Q1(b) (2 marks): The student has used a do loop on line 02. Describe the difference between a do loop and a while loop. [2]
  27. June 2024, Paper 2, Q1(c) (4 marks): Rewrite lines 05 to 07 to use a while loop instead of a for loop. You should write your answer using either program code or pseudocode. [4]
  28. June 2024, Paper 2, Q5(c) (4 marks): Write an algorithm, using pseudocode or program code, to call the function push() with the value 15 and output a message saying "Added" if the value was success
  29. June 2024, Paper 2, Q9(b)(i) (2 marks): The method getName() returns the data in the attribute name. Write the method getName() using pseudocode or program code. [2]
  30. June 2024, Paper 2, Q9(b)(ii) (3 marks): A global 1-dimensional array, allPrizes, stores 10 objects of type Prize. The prize in index 3 has the name "Box", the type is "money" and the value is 25. Writ
  31. June 2024, Paper 2, Q9(c)(i) (5 marks): new() is the constructor method. The name of the character is passed into the constructor as a parameter. The constructor then initialises both the experience a
  32. June 2024, Paper 2, Q9(c)(ii) (5 marks): The type and value of a prize are passed as parameters to the method updateValues. If the type is money the value is added to the character’s money. If the type
  33. June 2024, Paper 2, Q9(d) (6 marks): This incomplete pseudocode algorithm: • creates a new character with the name Jamal • loops until the character reaches the end of the road • generates a random
  34. June 2024, Paper 2, Q9(e) (4 marks): The procedure displayRoad() outputs the contents of each space in the road. The number of each space is output with either: • the word "empty" if there is no pr
  35. June 2024, Paper 2, Q9(f) (9 marks): A game is being written that makes use of object-oriented programming. A prototype for one part of the game is being designed that includes a character, a road
  36. June 2024, AS Paper 2, Q2(b)(i) (1 mark): Give the name of the parameter in the function enqueue. [1]
  37. June 2024, AS Paper 2, Q2(b)(ii) (1 mark): Give the name of one global variable that is used in the function enqueue. [1]
  38. June 2024, AS Paper 2, Q2(b)(iii) (4 marks): Describe one benefit and one drawback of using global variables instead of parameter passing in a subroutine. Benefit Drawback [4]
  39. June 2024, AS Paper 2, Q3 (9 marks): 3* Kofi and Zac both write a different pseudocode algorithm to read the data from a text file into an array. Kofi’s Algorithm Zac’s Algorithm fileName = "data.t
  40. June 2024, AS Paper 2, Q6 (8 marks): A program needs writing to allow a user to play the game fizz buzz. The rules are: • the user enters the numbers from 1 to 100 in turn • if the number is exactl
  41. June 2023, Paper 1, Q5(a) (1 mark): State the value returned from the function when doCheck(3178) is called. [1]
  42. June 2023, Paper 1, Q5(b) (5 marks): Write an algorithm that will: • allow the user to enter an integer value • pass the value entered into the doCheck() function as a parameter • store both the va
  43. June 2023, Paper 2, Q4(a)(i) (1 mark): Identify one identifier used in the function isInteger(). [1]
  44. June 2023, Paper 2, Q4(a)(ii) (1 mark): Give the line number where the branching (selection) construct starts in the function isInteger(). [1]
  45. June 2023, Paper 2, Q4(a)(iii) (1 mark): Give the line number where the iteration construct starts in the function isInteger(). [1]
  46. June 2023, Paper 2, Q4(b) (3 marks): Describe the purpose of the following lines in the function isInteger(). Line 03 Line 04 Line 09 [3]
  47. June 2023, Paper 2, Q5(a) (3 marks): Describe the key features of a recursive algorithm. You may refer to the function, recursiveAlgorithm() in your answer. [3]
  48. June 2023, Paper 2, Q5(b) (5 marks): Trace the recursive function, recursiveAlgorithm(), and give the final return value when called with recursiveAlgorithm(10). You may choose to use the table bel
  49. June 2023, Paper 2, Q6 (6 marks): Octal is a base 8 number system. To convert a denary number to base 8: • the denary value is divided by 8 and the remainder is stored • the integer value after
  50. June 2023, Paper 2, Q7(d) (6 marks): The programmer uses an Integrated Development Environment (IDE). Complete the table by identifying and describing three IDE features that can help the programme
  51. June 2023, Paper 2, Q9(b)(i) (5 marks): The constructor method takes a value as an integer, e.g. 100, and a level, e.g. "bronze", as parameters and assigns these to the attributes. Write pseudocode or
  52. June 2023, Paper 2, Q9(b)(ii) (2 marks): The get method getLevel() will return the appropriate attribute. Write the method getLevel() using either pseudocode or program code. [2]
  53. June 2023, Paper 2, Q9(b)(iii) (2 marks): Describe the object-oriented programming technique being used in part 9(b)(ii). [2]
  54. June 2023, Paper 2, Q9(c) (5 marks): A class, Board, is used to store the 10 row (x coordinate) by 20 column (y coordinate) grid. The design for the Board class, its attributes and methods is shown
  55. June 2023, Paper 2, Q9(d) (7 marks): A procedure, guessGrid(): • takes a Board object as a parameter • accepts the row (x) and column (y) coordinates from the user • outputs "No treasure" if there
  56. June 2023, Paper 2, Q9(e) (4 marks): Describe two benefits of using an object-oriented paradigm rather than a procedural paradigm. 1 2 [4]
  57. June 2023, Paper 2, Q9(f) (9 marks): A text-based computer game allows a user to dig for treasure on an island. The island is designed as a grid with 10 rows and 20 columns to store the treasure. E
  58. June 2023, AS Paper 2, Q1(b)(i) (3 marks): Explain why the procedure bubbleSort accepts the array numbers by reference and not by value. [3]
  59. June 2023, AS Paper 2, Q1(b)(ii) (1 mark): The programmer has used a for loop on line 3 in the procedure bubbleSort. A for loop is a count controlled loop. State what is meant by the term ‘count controll
  60. June 2023, AS Paper 2, Q3 (9 marks): 3* Nina is writing a computer game using an Integrated Development Environment (IDE). Her friend, James, is writing a computer game using a text-editor which wi
  61. June 2023, AS Paper 2, Q4(a) (6 marks): Write the function toBinary(). You should write your function using pseudocode or program code. [6]
  62. June 2023, AS Paper 2, Q4(b) (4 marks): The main program: • asks the user to enter a denary number between 1 and 255 • checks that the input is valid between 1 and 255 • If valid call the function toB
  63. June 2023, AS Paper 2, Q5(a)(i) (1 mark): Identify the construct used on lines 01 to 03 in the algorithm. [1]
  64. June 2023, AS Paper 2, Q5(a)(ii) (1 mark): Identify the construct used on lines 10 to 12 in the algorithm. [1]
  65. June 2023, AS Paper 2, Q5(b) (2 marks): Identify two variables used in this algorithm. 1 2 [2]
  66. June 2023, AS Paper 2, Q5(c) (4 marks): The algorithm that Layla has written has many errors. Identify the line number of four different errors and write the corrected line of code. Error 1 line numbe
  67. June 2023, AS Paper 2, Q5(d)(i) (1 mark): State what is meant by a ‘local variable’. [1]
  68. June 2023, AS Paper 2, Q5(d)(ii) (2 marks): Give one benefit and one drawback of declaring dataArray as a local variable in the main program. Benefit Drawback [2]
  69. June 2022, Paper 1, Q5(a)(i) (1 mark): State the value output by the line print(mystery(10,20)) [1]
  70. June 2022, Paper 1, Q5(a)(ii) (1 mark): State the value output by the line print(mystery(0,70)) [1]
  71. June 2022, Paper 1, Q5(a)(iii) (1 mark): State the value output by the line print(mystery(45,55)) [1]
  72. June 2022, Paper 1, Q5(e)(i) (3 marks): Complete the function below. function countCapitals(text) // initialise counter to 0 capCount = 0 // loop through each character in the string passed in for x =
  73. June 2022, Paper 2, Q1(b)(i) (2 marks): Identify two variables in the function useWords(). 1 2 [2]
  74. June 2022, Paper 2, Q1(b)(ii) (2 marks): numberOfWords is a parameter passed by value. Describe the difference between passing a parameter by value and by reference. [2]
  75. June 2022, Paper 2, Q1(b)(iii) (4 marks): Rewrite the function useWords() to use a while loop instead of a for loop. The function header and close have been written for you. Write your answer using pseu
  76. June 2022, Paper 2, Q1(c) (2 marks): Give one benefit and one drawback of declaring the array as a global variable instead of a local variable. Benefit Drawback [2]
  77. June 2022, Paper 2, Q1(d) (4 marks): Describe one feature of an Integrated Development Environment (IDE) that can be used to help write the program and one feature that can be used to help test the
  78. June 2022, Paper 2, Q6(b)(i) (1 mark): State the reason why checkValid() is a function and not a procedure. [1]
  79. June 2022, Paper 2, Q7(a)(i) (1 mark): Give the line number in the algorithm calculate() where a recursive call is made. [1]
  80. June 2022, Paper 2, Q7(a)(ii) (2 marks): State two features of any recursive algorithm. Feature 1 Feature 2 [2]
  81. June 2022, Paper 2, Q7(b) (5 marks): Trace the recursive function calculate() and give the final return value, when the following function call is run: calculate(5) You may choose to use the table
  82. June 2022, Paper 2, Q7(c) (1 mark): Give the pseudocode function call that would return 55 from the recursive function calculate(). [1]
  83. June 2022, Paper 2, Q8(b)(iii) (2 marks): The main program initialises a new object of type stack with the identifier mathsStack. Write pseudocode or program code to declare the object. [2]
  84. June 2022, Paper 2, Q8(b)(iv) (4 marks): The main program needs to: • take numbers as input from the user • push them onto the stack mathsStack until the stack is full • output an appropriate message i
  85. June 2022, Paper 2, Q8(b)(v) (8 marks): The main program also needs to: • remove one item from the stack at a time and add this to a total • output the total every time an item is removed • stop remov
  86. June 2022, Paper 2, Q8(c)(ii) (9 marks): The program is amended to include the use of several queue data structures. 8 A computer uses a stack data structure, implemented using an array, to store numbe
  87. June 2022, AS Paper 1, Q6(b) (2 marks): George will use iteration to read through the values in the text file. Describe how George can use iteration when reading from the text file. [2]
  88. June 2022, AS Paper 1, Q6(c) (7 marks): Write a procedure called salesAnalysis that will meet the rules of George’s program. You should write your procedure using pseudocode or program code. [7]
  89. June 2022, AS Paper 2, Q1(b) (1 mark): Ruhail will make use of an Integrated Development Environment (IDE). State the purpose of an IDE. [1]
  90. June 2022, AS Paper 2, Q1(c) (4 marks): State two different programming constructs and give an example of how Ruhail could use each construct when creating his program code. 1 2 [4]
  91. June 2022, AS Paper 2, Q2(a)(i) (4 marks): Explain why version one is more effective than version two at making sure that the telephone number entered is at least 11 characters long. [4]
  92. June 2022, AS Paper 2, Q2(a)(iii) (2 marks): When setting up the additional procedures in his program, Logan will use a mixture of parameter passing by reference and by value. State the difference between
  93. June 2022, AS Paper 2, Q2(b) (9 marks): Logan is writing a program for his customers to be able to buy his gym equipment. In the program, once a customer has selected the items they want to buy, a pro
  94. June 2022, AS Paper 2, Q3(b)(ii) (1 mark): Identify the name of the parameter used in the procedure bubbleSort. [1]
  95. June 2022, AS Paper 2, Q4(a) (2 marks): 07 number = number – 2 08 else 09 a = a + 1 10 print(a) 11 number = number – 1 12 endif 13 endwhile 14 endprocedure (a) Explain why = is used on line 11 of the
  96. June 2022, AS Paper 2, Q4(b) (1 mark): State the values printed by the procedure generate when number = 8. [1]
  97. June 2022, AS Paper 2, Q4(c) (1 mark): State the values printed by the procedure generate when number = 7. [1]
  98. June 2022, AS Paper 2, Q4(d) (2 marks): Describe the purpose of the MOD operator on line 04 of the procedure generate. [2]
  99. June 2022, AS Paper 2, Q5(b) (7 marks): A function findFirst, is used to find the first available appointment. Write the function findFirst that will find the first available appointment and return th
  100. June 2022, AS Paper 2, Q5(c) (1 mark): When an available time slot has been found then a valid customerID must be entered to confirm the booking. This is checked by another function called checkCusto
  101. June 2022, AS Paper 2, Q6(a) (2 marks): Describe how calculateChange() on line 04 is used differently to calculateChange() on line 06. [2]
  102. June 2022, AS Paper 2, Q6(b) (2 marks): When line 22 is run, it will always print: The amount of change you need is £0 Explain why this error occurs when line 22 is run. [2]
  103. June 2022, AS Paper 2, Q6(c) (3 marks): Explain why Kylie has used str on lines 22 to 25 in her algorithm. [3]
  104. November 2021, Paper 2, Q2(a)(ii) (1 mark): The algorithm uses a while loop. State a different type of loop that could be used instead of the while loop in the given algorithm. [1]
  105. November 2021, Paper 2, Q4 (9 marks): 4* Anna currently writes her program code in a text editor and then runs the compiler. She has been told that using an Integrated Development Environment (IDE)
  106. November 2021, Paper 2, Q5(a) (1 mark): The method new is used to denote the constructor for each class. State the purpose of the constructor. [1] The classes office and house inherit from building.
  107. November 2021, Paper 2, Q5(b) (2 marks): Describe what is meant by inheritance with reference to these classes. [2]
  108. November 2021, Paper 2, Q5(c) (5 marks): Part of the declaration for the class building is shown. Complete the pseudocode declaration by filling in the missing statements. class building private number
  109. November 2021, Paper 2, Q5(d) (6 marks): Write program code or pseudocode to declare the class house. Define the attributes and constructor method in your answer. You do not need to write the get or se
  110. November 2021, Paper 2, Q5(e) (4 marks): Christoff develops a new class to store the houses in one road. His class design is shown: class : houseRoad attributes: private buildings(100) //array of class
  111. November 2021, Paper 2, Q5(f) (4 marks): Christoff wants to create a new house called houseOne. It has the properties: 2 floors, 8(m) width, 10(m) height, 3 bedrooms and 2 bathrooms. The house is locat
  112. November 2021, Paper 2, Q8(b)(i) (5 marks): Juan
  113. November 2021, Paper 2, Q8(b)(ii) (2 marks): Exp
  114. November 2021, Paper 2, Q8(b)(iii) (3 marks): De
  115. November 2021, Paper 2, Q8(b)(iv) (6 marks): The
  116. November 2021, Paper 2, Q8(b)(v) (3 marks): The
  117. November 2021, Paper 2, Q8(c) (9 marks): A Nonogram is a logic puzzle where a player needs to colour in boxes. The puzzle is laid out as a grid and each square needs to be either coloured black or left
  118. November 2021, Paper 2, Q8(d) (4 marks): Juan wants to create a program that will generate new Nonograms with different grid sizes. For example a Nonogram with a 10 × 10 grid or a 5 × 20 grid. Describe

Questions, mark schemes and examiner’s reports are © OCR, from their published past papers. Plumi isn’t affiliated with any exam board. Want whole papers? Full past papers.

Rather write your answers by hand on iPad? Plumi marks them against the same mark schemes.