Declaring a variable to hold file data
Creates a variable named LineOfText that holds text. Declare it before the file commands that use it, for example before READFILE stores a line in it.
Understanding Declaring a variable to hold file data in IGCSE Computer Science Paper 2
What it does: The variable LineOfText exists before READFILE stores a line of text in it. PlayerName tells the reader what the variable holds, and STRING matches text data. In 0478 pseudocode the form is DECLARE <identifier> : <data type>, with a colon between the name and the data type. DECLARE only creates the variable. OPENFILE is the command that opens the file.
Common mistakes: The colon is missing. A declaration needs the form DECLARE <identifier> : <data type>, so it should be DECLARE LineOfText : STRING. A declaration uses a colon between the identifier and the data type, not an equals sign. It should be DECLARE LineOfText : STRING.
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 479–488) and word search (Modules 479–499).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
DECLARE LineOfText : STRINGFill in the Blanks
Spot the Error
Student with a class code? Join your class →