9618/32/M/J/25 question 13: worked solution (May/June 2025, paper 32)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 20.2 File Processing and Exception Handling Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 2 of 2. Q30 9618/32/M/J/25 original Q13 Structured · 5 marks Worked solution Open the live file too. Loop through the 50 records, add the text if the grade is missing, then SEEK in the stored file and write the record. DECLARE Grade : StudentResult DECLARE Position : INTEGER OPENFILE "CurrentResults.dat" FOR RANDOM OPENFILE "StoredResults.dat" FOR RANDOM FOR Position ← 1 TO 50 SEEK "CurrentResults.dat", Position GETRECORD "CurrentResults.dat", Grade IF Grade.ExamGrade = "" THEN Grade.ExamGrade ← "Missing grade" ENDIF SEEK "StoredResults.dat", Position PUTRECORD "StoredResults.dat", Grade NEXT Position CLOSEFILE "CurrentResults.dat" CLOSEFILE "StoredResults.dat" OPENFILE "CurrentResults.dat" FOR RANDOM [1] FOR Position ← 1 TO 50 [1] Grade.ExamGrade ← "Missing grade" inside the IF [1] SEEK "StoredResults.dat", Position [1] PUTRECORD "StoredResults.dat", Grade [1] KEY IDEA With random files, SEEK to the record position before each GETRECORD or PUTRECORD. TOTAL 5 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by James Gan. Tap the picture to open it on YouTube.