Global variables and constants
Computer Studies · Grade 10 · about 40 minutes
A name outside every function is global. Use it sparingly, mainly for true constants such as VAT 0.16.
Sign in to read this lesson
Lessons are for learners and teachers with an account. Browsing the curriculum — subjects, strands and what each sub-strand covers — stays open to everyone.
- 8 sections of explanation, worked examples and diagrams
- 1 practice task with hints and worked answers
- A quiz that marks itself as you go
- Your progress kept across every subject you take
Other lessons in this sub-strand
- Functions and modular programming
- Parameter passing and variable scope
- Why modular programming
- Built-in functions in practice
- Writing a function definition
- Parameters: giving a function data
- Return values: getting a result back
- Functions calling functions
- Formal and actual parameters
- Local variables in practice
- Global variables and constants
- Value-returning and void functions
- Building a modular program
- The roles of functions