Local and global variables (Edexcel GCSE Computer Science): Quizzes
📚Quizzes
Practise the questions
12 questions from this quiz
ShowHide
Practise the questions
12 questions from this quiz
What does 'scope' refer to in programming?
What does 'scope' refer to in programming?
Where a variable can be accessed
What is a local scope?
What is a local scope?
Area within a single subprogram
Where can a local variable be accessed?
Where can a local variable be accessed?
Only within its subprogram
What happens to a local variable after its subprogram finishes running?
What happens to a local variable after its subprogram finishes running?
It disappears
What is global scope?
What is global scope?
Covers the entire program
Where can global variables be accessed from?
Where can global variables be accessed from?
Main program and all subprograms
How long do global variables exist?
How long do global variables exist?
For the entire program duration
When a program encounters a variable name, which scope is checked first?
When a program encounters a variable name, which scope is checked first?
Local scope
Can variables with the same name exist in different scopes?
Can variables with the same name exist in different scopes?
Yes, without interfering
What is a key benefit of local variables?
What is a key benefit of local variables?
Prevent accidental changes
How do you identify if a variable is local or global?
How do you identify if a variable is local or global?
Where it is declared
If 'total' is global and also declared locally in a function, which is used inside the function?
If 'total' is global and also declared locally in a function, which is used inside the function?
The local version
