Skip to main content
A-LevelComputer ScienceProgramming9618/41 · Oct/Nov 2022 · Q123 Marks

The text file IntegerData.txt stores 100 integer numbers between 1 and 100 inclusive. A program is required to read in this data and perform searching and sorting on the data.

  1. (a)Write program code to declare a global 1D array, DataArray, with space for 100 integer values.[2]
  2. (b)The procedure ReadFile() must read in the numbers from the text file and store each one in the array. Use appropriate exception handling. Write program code for the procedure ReadFile().[6]
  3. (c)The function FindValues() asks the user to enter a number to search for in the array. The number input must be a whole number between 1 and 100 inclusive. The function then returns the number of times the number input appears in the array. Write program code for the function FindValues().[7]
  4. (d)(i)Write program code to call ReadFile() and FindValues() from the main program. The return value from FindValues() must be output with an appropriate message.[3]
  5. (d)(ii)Test your program using the number 61 as input. Take a screenshot to show the output. Copy and paste the screenshot into part 1(d)(ii) in the evidence document.[1]
  6. (e)The procedure BubbleSort() needs to perform a bubble sort on the array and print the contents of the sorted array. Write program code for the procedure BubbleSort() and call it from the main program.[4]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.

  1. 1 mark per point:
  2. [1] (global) 1D (Integer) array DataArray
  3. [1] 100 elements
  4. 1 mark per point:
  5. [1] Procedure ReadFile() header (and end where appropriate)
  6. [1] opening file IntegerData.txt (for read)
  7. [1] looping through the 100 elements // looping to end of file
  8. [1] reading each (and all) value from file and storing in array
  9. [1] closing file (in appropriate place)
  10. 1 mark per point:
  11. [1] Exception Handling (for opening the file, or for reading values from the file)...
  12. [1] ...with appropriate catch and output messages
  13. 1 mark per point:
  14. [1] Function FindValues()(and end where appropriate) and input of data to search for in the array
  15. [1] ...validation/casting(/storing as) of input as integer
  16. [1] .validation of input between 1 and 100 (inclusive)
  17. [1] looping through all 100 array elements...
  18. [1] .comparing input to each array element...
  19. [1] .initialising counter to 0 and then adding 1 each time it is found...
  20. [1] Returning the total
  21. 1 mark per point:
  22. [1] Calling ReadFile() and then FindValues() (in the main program)
  23. [1] storing/using return value from FindValues()
  24. [1] ...outputting return value with appropriate message
  25. [1] Screenshot showing 61 input and 2 output, e.g.
  26. 1 mark per point:
  27. [1] procedure declaration (and end where appropriate) and outputting array contents at end of procedure and calling procedure from main program
  28. [1] correct outer loop
  29. [1] correct inner loop ...
  30. [1] swapping all elements if in incorrect order

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Programming, A-Level Computer Science (syllabus 9618). Structured question, 23 marks.
Source
A-Level Computer Science, Oct/Nov 2022 Paper 4 Variant 1, question 1.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep