Explain the difference between a variable and a constant
Value of a variable can change at runtime, value of a constant cannot
Explain the advantages of using named constants instead of hard-coded values. [2]
When the programmer wants to change the value it only needs changing in the declaration;
Can’t be changed accidentally/by the program;
Easier to understand the program / purpose of the data item stored in the constant so easier to debug;
What is a subroutine?
A named out-of-line block of code that can be called by writing its name.
What is a local variable?
A variable declared inside a subroutine which exists only while the subroutine is executing, and is only accessible inside the subroutine it is declared in.
What is a global variable?
A variable declared outside of a subroutine which is accessible to all parts of the program.
Explain why it is considered good practice to use local variables [3]
• Local variables use less memory // memory allocated to local variables can be reused when subroutine not in use;
• Using local variables makes subroutine self-contained;
• Using local variables aids modularisation;
• Variable names can be reused (in other parts of the program);
• Code is easier to re-use in other programs;
State three advantages of using subroutines and explain how each advantage is achieved
What is procedural abstraction?
The result of abstracting away the actual values used in any particular computation is called a procedure.
What is functional abstraction?
Functional abstraction disregards the particular computation method used.
What is problem decomposition?
Breaking a problem into a number of sub-problems, so that each sub-problem accomplishes an identifiable task, which might itself be further subdivided