Variables, Constants & Assignment Flashcards

All 6 cards in this deck

What is a variable in programming?

A named memory location whose value can change while the program is running.

What is a constant in programming?

A named value that is set once and cannot change while the program is running.

Give one reason to use a constant instead of a variable in a program.

The value cannot be changed accidentally, and it only needs editing in one place.

What is an assignment statement?

A statement that gives a value to a variable. In AQA pseudo-code it uses ←, e.g. score ← 0.

True or false? In AQA pseudo-code, = is used to assign a value to a variable.

False. = tests whether two values are equal; ← is used for assignment, e.g. total ← 0.

How is a named constant declared in AQA pseudo-code?

e.g. a constant for pi

With the keyword CONSTANT, then the name and its value: CONSTANT PI ← 3.141