Variable roles Flashcards Preview

COMPUTING > Variable roles > Flashcards

Flashcards in Variable roles Deck (14):
1

What does a fixed value variable do?

The value of the variable is not changed whilst the program is running after initialisation

2

What does a stepper variable do?

Goes through a series of values in a systematic way
(eg. a counter for a loop, going through an array, counting)

3

What does a most-recent holder variable do?

Changes to hold the latest current value and is regularly updated

4

What does a most-wanted holder variable do?

The 'best' value out of the values gone through at that point. What is most wanted depends on the program, eg. smallest, largest, closest to a certain number etc

5

What does a gatherer variable do?

Accumulates all values gone through so far

6

What does a follower variable do?

Always takes the old value of another variable as its own value

7

What does a transformation variable do?

Always gets its value from a fixed calculation using other variable's values
eg. variable 1 = contents of variable 2 x 5, the 5 doesn't change

8

What does a temporary variable do?

Its value is only needed for a very short time

9

What is a value parameter?

A parameter in a subroutine which enables a one way only flow of data from main program into routine.
The routine cannot change the global value of the variable
=routine variable in brackets without var in front of it

10

What is a reference parameter?

A parameter in a subroutine which enables a two way flow data between main program and routine, routine can change the global value of a variable
=routine variable with VAR in front of it in the brackets

11

What is the difference between a procedure and a function?

Both are subroutines but a function always returns a value, procedures just executes commands

12

What is a global variable?

Declared at the start of the program and can be used in any subroutine without being declared or passed again
They use memory even when not being used

13

Why is it better to use local variables than global variables, where possible?

-Makes program more easy to read and understand
-Makes subroutines easier to re-use
- Global variables can have unexpected side effects
-Global variables use memory even when subroutine is not being executed.

14

What is a local variable?

Declares at the start of a subroutine, can only be used in the subroutine they were declared in unless passed to a different part of the program
They only use memory when their subroutine is being executed