Local compared with global variables
A local variable is declared inside a subroutine and only exists and works there while it runs. A global variable is declared outside and can be used anywhere in the program all the time.
Understanding Local compared with global variables in IGCSE Computer Science Paper 2
What it does: Inside Reset, Count means the local variable. Setting it to 0 does not change the global Count. Total is declared outside every subroutine, so ShowTotal can output it directly. A global variable has global scope, so every subroutine and the main program can use it. Each local variable belongs only to its own subroutine, so the same name can be reused safely.
Common mistakes: Num is a parameter, which is a local variable that only exists inside Show. The main program cannot use it. The call must pass a real value, such as CALL Show(7). Declaring Lives inside Reset creates a new local variable with the same name, which hides the global one. The global Lives is never set. Remove the DECLARE and assign Lives ← 3 so the global is changed.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 419–428) and word search (Modules 419–438).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
local vs globalFill in the Blanks
Spot the Error
Student with a class code? Join your class →