What is the difference between local and global variables?

Local variables are defined within a subroutine. Their scope/visibility ends when the cursor leaves the subroutine.
Global variables on the other hand are variables that exist outside of all the subroutines and functions, and are available to all of them.

CD

Related Computing A Level answers

All answers ▸

Describe the difference between a CPU and a GPU with relation to processing power and ability to perform tasks.


Why indentation is important in Python and what is the scope of a global variable?


Simplify the following Boolean expression: ¬(AvB) v ¬(CvD) v ¬A^(BvC) v (¬A^A)


What is the difference between a high level language and a low level language?