3.1.1.6 Constants and variables in a programming language. Flashcards
1
Q
Define a constant.
A
Data values that stay the same every time a program is executed. Constants are not expected to change and can not be overwritten later in the program.
2
Q
Define a variable.
A
A variable is a memory location, with a name that is associated with that location and are used for holding data.
3
Q
Outline the differences between a variable and a constant.
A
A constant does not change its value over time. A variable, on the other hand, changes its value dependent on the equation and can change during the programs execution.
4
Q
Outline the advantages of using named constants.
A
- There is no need to repeatedly type the same value.
- Only at one place the value of the constant needs to be updated in order to change it.
- It makes programs easily readable.