Programming · 4 question types
Past paper frequency (2018 to 2024)
This topic accounts for approximately 3% of your exam marks.
OPENFILE, READFILE, WRITEFILE, CLOSEFILE pseudocode operations appear occasionally.
Every file that has been opened must be closed before the program ends. Forgetting
CLOSEFILEcan lose data or corrupt the file.
When a program writes to a file, the operating system does not always send the data straight to the disk. Instead, the data sits in a buffer in RAM, ready to be written in efficient chunks. The file is only flushed (written out to disk) when:
If the program ends without closing the file, the buffered data may never reach the disk, and the file is left incomplete or empty.
CLOSEFILE doesCommon slip: forgetting
CLOSEFILEat the end of a file-writing algorithm. Even if a question awards no specific mark for it, the algorithm is incomplete without it.