Comp1-variable roles. Flashcards
What is a fixed value variable?
The role of a variable is a fixed value if its value is not changed while the program is running after initialization.
(its changed at the start)
What is a stepper variable?
Stepper goes through a succession of values in some systematic way.
What is a most-recent holder?
A variable is a most-recent holder if its value is the latest gone through value of a certain group or simply the latest input value.
What is a most wanted holder?
The value of a most-wanted holder is the best or otherwise the most-wanted value out of the values gone through so far. could be the smallest number or biggest , the best is defined by the programs needs.
What is a gatherer variable?
The value of a gatherer is to accumulate all the values gone through so far.
what is a follower variable?
A follower always gets the old value of another known variable as its new value.
What is a transformation variable?
A variable is a transformation variable if it always gets its new value from a fixed calculation of values of other variables.
What is a temporary variable?
A variable is a temporary if its value is always needed only for a very short period.
Whats the difference between a value parameter and a reference parameter.
Value parameters are used to pass values into a subroutine. Reference parameters are variables use to pass information in and out of a subroutine. They enable the subroutine to change the values of the variables in the calling block.
Why use local variables instead of global variables?
Easier reuse of routines in other programs;
Routine can be included in a library;
Helps to make the program code more understandable; routine is independent of the rest of the program;
(Global variables use memory while a program is running) reduces possibility of undesirable side effects;
Using global variables makes a program harder to debug;
Why can local and global variables have the same identifier?
They are stored in different memory locations
the local takes priority from inside the subroutine.