Question 2(c) 2025 · May-June · Paper 41 · 5 marks
Reveal official mark-scheme answer

Official answer for Question 2
Part (c)
Question 1
mark each
Question 5
- Procedure header taking (1D) array and filename as parameters, opening file to append and closing file (in appropriate
- Looping through each item in array parameter …
- … writing to the file
- … with new line break between each line
- Using exception handling try and catch with suitable output
Show text version of question
Question 2
Part (c)
Question 2
A program reads data from a text file, splits the data depending on its content and stores the
separated data into different files.
The text file TheData.txt contains 72 lines of data. Each line of data has an integer number and a string colour that are separated by a comma. For example, the first line in the file is:
10,red
The integer is 10 and the string is "red"
The file contains six different colours: red, green, blue, orange, yellow, pink.
Part (c)
The procedure StoreData():
- takes two parameters: a 1D array DataToStore and a filename
- opens the text file with the filename that is passed as a parameter
- appends each item of data from DataToStore to a new line in the text file
- uses exception handling when opening and writing data to the text file.
Write program code for StoreData()
Save your program.
Copy and paste the program code into part 2(c) in the evidence document.
Why this question appears here
71% assigned-topic match · Programming › Structured programming
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_s25_qp_41.pdf
