3.1.1.13 Local variables in subroutines. Flashcards
1
Q
Define the relationship between variables and subroutines.
A
Subroutines may declare their own variables, known as local variables.
2
Q
Outline the rules of local variables.
A
Local variables only exist while the subroutine is executing and are only accessible within the subroutine.
3
Q
Why is it good practice to use local variables?
A
- You can give local variables the same name in different functions because they are only recognised by the function they are declared in.
Local variables are deleted as soon as any function is over and release the memory space which it occupies.