AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Programming concepts: constant declaration
A constant is a named store whose value is fixed once set and cannot be changed while the program runs.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 3 of 23
Study notes
From the checked teaching notes for this specification point.
The idea
A constant is a named store whose value is fixed once set and cannot be changed while the program runs. Declaring a constant gives it a name and a value at the point of definition, and the translator then prevents any later reassignment. For example, a program calculating the area of a circle might declare a constant for pi and use it throughout, so the value is written once and cannot be altered accidentally. Using constants improves readability and makes maintenance easier, because changing the value in one place updates every use. Attempting to reassign a constant should raise an error, which helps prevent bugs caused by unintended changes.
What earns the marks
- A constant is a named store whose value is fixed at declaration and cannot be changed during execution.
- A constant is given its value when it is declared, unlike a variable that may be assigned later.
- The translator prevents reassignment of a constant, so attempting to change it causes an error.
- Using constants improves readability and maintenance because the value is defined in one place.
- Constants suit fixed values such as pi or a maximum array size that must not change.
Common mistakes and how to put them right
Treating a constant as a variable that simply happens not to change.
Put it right by stressing that the language enforces the fixed value.
Thinking a constant can be declared without a value and set later.
Put it right: Explain that a constant must be given its value at declaration.
Believing constants are only for numbers.
Put it right: Note that a constant can hold any fixed value, including text.
Exam tips
- Eliminate options that allow the value to be reassigned, since that describes a variable.
- Look for the idea that the value is set once at declaration and enforced by the translator.
- Link the answer to benefits such as readability and easier maintenance.
Try the lesson
The start of the Programming concepts: constant declaration lesson, made from checked teaching notes for this specification point.
Have a go first
A programmer wants to store the number of days in a week so that the value cannot be changed while the program runs. Which programming construct should be 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: constant 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