Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0984

Store program data in files

Explain why a program saves data to a file and how a later run can use it again.

Section 8 · Programming

Cambridge IGCSE Computer Science 0984 · Programming · 2026–2028 Version 4 · 0984 (9–1) · 8.3
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers section 8.3 (File handling) only. Pseudocode examples use the published Cambridge format; the separate 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers, a browser-based programming workspace and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.

Before you begin

  • Be comfortable following an ordered algorithm and tracing variable values. Each lesson introduces the Cambridge pseudocode form it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

What usually happens to an ordinary variable when its program ends?

What you will learn

  • Explain persistence beyond one run
  • Distinguish file storage from a temporary variable
  • Choose an appropriate file for a simple scenario

A file keeps data between runs

Variables and arrays hold values while a program is running. When the program ends, those working values are normally lost unless data is saved to persistent storage.

A file stores data on backing storage so a later run can read it. Examples include saving a score list, configuration settings or a record of bookings.

Choose file content for the program's need

Use a file when data must be kept, transferred or processed in a later session. Decide what information is needed and how a line or item will be interpreted.

File operations need an explicit mode and should be closed when finished. Opening in WRITE mode creates a new file and can erase existing contents, so use it carefully in the algorithm design.

Pause and explain

A program needs to reload a saved list on the next launch. Which storage choice fits?

Put the idea to work

Worked example

A quiz program must keep a learner's best score after the program closes. Why is a file suitable?

Show the worked solution
  1. A variable is temporary while the program runs.
  2. The best score is needed in a later run.
  3. Write the score to persistent storage and read it next time.

Answer Store the best score in a file so a later run can retrieve it after the original program has ended.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

Give one example of data that should persist between sessions and explain why.

Give me a hint

Choose data that the user expects to find after closing the program.

Compare my reasoning
  1. Name a value such as a saved high score.
  2. Explain that the program ends but the result is still needed.
  3. Store it in a file for the next run.

A best score can be saved in a file so it remains available after the quiz closes.

Look for these in your work

  • Persistent data identified
  • Later use explained
2 · Independent

Explain one difference between a variable and a file for storing a learner's answer.

Give me a hint

Think about lifetime and persistence.

Compare my reasoning
  1. A variable holds a value during program execution.
  2. A file can retain data between program runs.
  3. Choose according to whether later retrieval is required.

A variable is temporary working storage; a file persists so a later run can retrieve the answer.

Look for these in your work

  • Variable role
  • File role
3 · Transfer

A program opens a history file in WRITE mode to add a new entry. What risk should the design consider?

Give me a hint

Check the documented effect of WRITE mode.

Compare my reasoning
  1. WRITE creates a new file if needed.
  2. Existing contents may be lost.
  3. Preserve old data by reading and rewriting it or use a suitable append feature only if the specification allows it.

Opening in WRITE can erase existing contents, so the design must preserve earlier records if they are needed.

Look for these in your work

  • Mode effect
  • Data-preservation risk

Common mistakes

  • Assuming an ordinary variable persists after the program stops
  • Opening an existing file in WRITE mode without considering data loss
  • Forgetting to close the file
Recall without your notes

What can you explain now?

Why might a program store data in a file?

Compare with the explanation

To keep data for later use

A file persists beyond the current program run.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

What requirement makes file storage necessary when a program closes?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science (9-1)

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 4 syllabus. Cambridge states that 0984 has the same subject content as 0478, with 9–1 grading. Three retained introductory lessons remain available but are not counted as syllabus-mapped teaching. The 2023–2025 syllabus remains unmapped. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. Practical programming in an executable browser workspace, full timed-paper practice and human subject-teacher review remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.