Professional Documents
Culture Documents
Revision - Week 12
Revision - Week 12
– Functions;
– Pass by value or by reference;
– Variable scope; and
– Arrays.
Revision
• Where to put your functions???
Option 1
• Place your function before the main function
• Requires to put the function before it first use
by any other function.
Option 2
• Place your function after the main function
• Problem: The compiler works top down. It will
complain about undefined functions..
• Unless … You put a so-called prototype before
all functions.
• Scope
• Two different scopes to care about
• Local scope: Relevant within one function..
• Global scope: The scope defined by the entire
file.
Local Scope - Where to put your variables?
Global Scope
Global Scope
• Not a good idea!!!
Value Parameters
Reference Parameter
Arrays
• They are used to store a group of objects/
variables.