Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 2 of 2.
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]
▶ Topic lesson
A lesson on this topic · by James Gan. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.