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 ▸

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


In Python, write a recursive function that returns the first n Fibonacci numbers.


What is the main difference between the Stack and the Queue abstract data types?


What is the difference between a RISC and CISC processor?