Javascript required
Skip to content Skip to sidebar Skip to footer

A(N) ____ Is a Named Memory Location Whose Value Can Vary.

Constants and variables

In a programme, data values tin can exist constant or variable . If values are variable they tin can be changed by the program and the user.

When a program is run, the data values are held in retentiveness whilst they are being worked on.

Constants

Data values that stay the same every time a plan is executed are known as constants. Constants are non expected to change.

Literal constants are actual values stock-still into the source code . An example of this might be the character string "hi world". The data value "hello world" has been fixed into the code.

Named constants are values where a name is divers to be used instead of a literal constant. An example of this might be stating that the 'starting level' of a game is always referred to as 1.

Examples of a constant within a game might exist:

  • the unit of measurement of gravity
  • the number of lives available for the histrion
  • the amount of time allowed for a level in a game

Variables

Variables are data values that can alter when the user is asked a question, for instance, their historic period. Variables may alter during program execution.

A variable is a retentiveness location . It has a name that is associated with that location. The memory location is used to hold data. The key difference when comparing a constant to a variable is that the value associated with a variable name may change during programme execution. For case 'highScore' would demand to be variable to change throughout a game.

Diagram demonstrating a Boolean algorithm

The content and arrangement of a computer's memory is non fixed - so neither is the value that is pointed at past a variable.

When data is read from a variable, the content of the retentiveness location is copied and used in calculations.

dodgshunalogethe.blogspot.com

Source: https://www.bbc.co.uk/bitesize/guides/zc6s4wx/revision/5