Skip to content

Lesson 45: Local or global

Where can a variable be used?

  • The scope of a variable is the part of the program that can use it.
  • A global variable is made outside all functions. Every part of the program can use and change it.
  • A local variable is made inside a function. Only that function can use it, and it is new each time the function runs.

Words for this lesson

Word Meaning
scope where in the program a variable can be used
global variable can be used anywhere in the program
local variable can be used only inside its function

Log in or create account

IGCSE, A-Level & AP