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 ▸

Calculate -3 + 3 using Two's Complement and the Sign and Magnitude Method. Which works correctly?


Write pseudocode for the binary search algorithm and state, with an explanation, it's worst case complexity in big-O notation


One member of a chess club sends a text file saved in Unicode. What meant by the term "Unicode" and why might this be necessary?


How can XOR be used in encryption and what type of encryption is this ?