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. The procedure SplitData() takes a 1D string array as a parameter with the identifier DataArray The procedure declares six 1D arrays: one array for each colour that appears in the file (red, green, blue, orange, yellow, pink). The procedure accesses each string in DataArray. The data in each string is split into the integer and the colour. The integer is stored in the array that matches the colour. For example, the first string in DataArray has the integer 10 and the colour red, so the integer 10 is stored in the array for the colour red. Write program code for SplitData()

Computer Science
IGCSE&ALevel
CAIE
Exam No:9618_s25_qp_41 Year:2025 Question No:2(b)

Answer:











Knowledge points:

20.2 File Processing and Exception Handling

Solution:

Download APP for more features
1. Tons of answers.
2. Smarter Al tools enhance your learning journey.
IOS
Download
Android
Download
Google Play
Download