Variables vanish the moment a program stops, so when we need data to survive we write it to a file on backing storage. In this lesson we cover why files are used and the Cambridge pseudocode text-file operations: opening a file for READ, WRITE or APPEND, reading to the end of the file, writing and closing it.
1. What is the main reason a program stores data in a file rather than only in variables?
2. A file already contains data. What happens if it is opened using OPENFILE "scores.txt" FOR WRITE and then written to?
3. During a reading loop, what does EOF("data.txt") return TRUE for?
4. A program must add one new record to a file without deleting the records already stored. Which mode should be used?
Practise exam-style questions on this
Type your answer, see your mark against the mark scheme in seconds. Free, 5 a day.
Start practising →
Teaching this topic?
Mark your whole class's answers and see who's stuck, for £19 a month.
See the class plan →
Free revision content. Multiple-choice answers are marked instantly. Written answers are marked by AI on /free-mark. Independent, not endorsed by Cambridge International.