AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Programming concepts: variable declaration
A variable is a named store whose value can change while a program runs.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 2 of 23
Study notes
From the checked teaching notes for this specification point.
The idea
A variable is a named store whose value can change while a program runs. Declaring one tells the translator the name you will use and, in a language that requires it, the data type it will hold, so memory can be reserved and type checking applied. For example, in a strongly typed language you might write a declaration giving a name and an integer type before assigning a starting value; in Python you simply assign a first value and the name is created. The declaration itself does not have to give a value, but the variable must be given one before it is read. Choosing a meaningful name and the correct type prevents errors such as storing text where a number is expected.
What earns the marks
- A variable is a named location in memory whose stored value can be changed during execution.
- A declaration introduces the identifier and, where the language requires it, the data type, so the translator can reserve storage and check types.
- A declaration may be separate from assignment; the variable must hold a value before it is used.
- Choosing a meaningful identifier and an appropriate data type reduces errors such as type mismatches.
- In some languages (for example Python) a first assignment both creates and initialises the variable.
Common mistakes and how to put them right
Thinking a variable cannot change value.
Put it right by stressing that a variable's value may be reassigned during the program.
Confusing declaration with assignment.
Put it right: Explain that declaring introduces the name and type, while assignment stores a value.
Assuming every language needs an explicit type in the declaration.
Put it right: Note that dynamically typed languages infer the type from the assigned value.
Exam tips
- Read the whole option before choosing; eliminate options that describe a constant rather than a variable.
- Link the answer to the idea of a changeable value and, where relevant, a declared data type.
- If two options look similar, decide which one correctly separates declaration from assignment.
Try the lesson
The start of the Programming concepts: variable declaration lesson, made from checked teaching notes for this specification point.
Have a go first
In a program, what is the main purpose of declaring a variable before it is used?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Programming concepts: variable declaration
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge