← IGCSE Computer Science Paper 2

Component parts of a problem: storage

Data the solution must keep, in a variable, file or database, so it can be used again later. It is not the same as input or output.

Understanding Component parts of a problem: storage in IGCSE Computer Science Paper 2

What it does: Writing the value to a file stores it after the program stops, so it can be read back and used again later. A database is storage for many records. The query reads stored data back, so it does not store anything new. Showing data to the user is output. Output is not the same as storage. Storage is where the name is kept after it is entered, for example in a variable, file or database.

Common mistakes: The comparison is the wrong way round. A new score should replace the stored high score only when it is greater, so the line should be IF Score > HighScore THEN. The program is saving the high score so it is kept after the program stops. It must write to the file with WRITEFILE, not read from it with READFILE. The line should be WRITEFILE "hs.txt", HighScore.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 94–106) and word search (Modules 94–118).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A quiz program keeps the player's score in a variable while the game runs. Is this storage?
No, only files count as storageYes, the data is kept so it can be used again later
Matches
Storage: the user types in their name
↓
This describes input, not storage. Typing a name gets data into the program but does not keep it for later.
Applying
Meanings
Term
storage
Meaning
Data the solution must keep, in a variable, file or database, so it can be used again later. It is not the same as input or output.
Practice
HighScore ← 0
Testing
Gaps
HighScore : INTEGER
Check Answer
Spots
3INPUT Score
4IF Score < HighScore THEN

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Zebra' badge — Pattern Matcher, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A quiz program keeps the player's score in a variable while the game runs. Is this storage?
A. Yes, the data is kept so it can be used again later ✓
B. No, only files count as storage
Storage can be a variable, file or database. A variable keeps data while the program is running.
2. Which data is still there after the program has stopped?
A. A score kept only in a variable
B. A high score saved in a file ✓
Variables are cleared when the program stops. A file keeps its data after the program ends.
3. A school needs to keep the records of 500 students and search them later. Which storage fits best?
A. A database ✓
B. One single variable
A database keeps many records and lets you search them. One variable only holds a single value.
4. A player types their name on the keyboard. What is this part of the problem?
A. Storage
B. Input ✓
Typing data in is input. It becomes storage only when the program keeps it to use again later.
5. The program shows 'Game over' on the screen. What is this part of the problem?
A. Output ✓
B. Storage
Showing data to the user is output. Output is not the same as storage.

Match the Pairs

storage → The data a solution must keep, in a variable, file or database, so it can be used again later
highScore ← 0 → A variable holding data that is kept only while the program is running
A high score must still be there next time the game is played, so it is saved in a file → WRITEFILE "scores.txt", highScore
Records, such as a student's name and mark, are kept in a database so they can be used again later → SELECT name, mark FROM results
Storage: the user types in their name → This describes input, not storage. Typing a name gets data into the program but does not keep it for later.
Storage: the program shows the final score on the screen → This describes output, not storage. Displaying a score shows data to the user but does not keep it.

Key Term

storage
Data the solution must keep, in a variable, file or database, so it can be used again later. It is not the same as input or output.

Fill in the Blanks

1. DECLARE HighScore : INTEGER HighScore ← 0
Hint: Type the keyword that creates a variable to hold data while the program runs.
2. OPENFILE "scores.txt" FOR WRITE
Hint: Type the file mode used when saving data so it is kept after the program stops.
3. OPENFILE "scores.txt" FOR WRITE WRITEFILE "scores.txt", HighScore CLOSEFILE "scores.txt"
Hint: Type the command that saves a value into the open file.
4. OPENFILE "scores.txt" FOR READ READFILE "scores.txt", HighScore CLOSEFILE "scores.txt"
Hint: Type the command that loads a stored value from the file back into a variable.
5. INPUT NewScore HighScore ← NewScore OUTPUT HighScore
Hint: Type the variable holding the value that is kept in HighScore, which is storage and not input or output.

Spot the Error

Question 1
A DECLARE HighScore : INTEGER
B HighScore ← 0
C INPUT Score
D IF Score < HighScore THEN
E HighScore ← Score
F ENDIF
Line D — The comparison is the wrong way round. A new score should replace the stored high score only when it is greater, so the line should be IF Score > HighScore THEN.
Question 2
A OPENFILE "hs.txt" FOR WRITE
B READFILE "hs.txt", HighScore
C CLOSEFILE "hs.txt"
Line B — The program is saving the high score so it is kept after the program stops. It must write to the file with WRITEFILE, not read from it with READFILE. The line should be WRITEFILE "hs.txt", HighScore.
Question 3
A DECLARE Lives : INTEGER
B Lives = 3
C INPUT Guess
D Lives ← Lives - 1
Line B — In Cambridge pseudocode, = is used to compare values. Storing a value in a variable needs the assignment arrow, so the line should be Lives ← 3.
Question 4
A OPENFILE "hs.txt" FOR READ
B READFILE "hs.txt", OldScore
C INPUT OldScore
D CLOSEFILE "hs.txt"
Line C — OldScore was already read from storage in the file. Showing it to the user is output, so the line should be OUTPUT OldScore. Storage is not the same as input or output.
Question 5
A Total ← 0
B INPUT Sale
C Total ← Sale
D OUTPUT Total
Line C — This overwrites the stored total instead of adding to it, so earlier sales are lost. The line should be Total ← Total + Sale.

Student with a class code? Join your class →