3.1.1.6 Constants and variables in a programming language. Flashcards

You may prefer our related Brainscape-certified 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly