Lecture 5
Lecture 5
Lecture 5
Chapter 7
Philip Robinson
2017
Functions
3
Functions
• The return type and argument declaration are optional, i.e for
no return type or arguments use type void.
• Variables other than arguments are declared within the body,
which is bounded by braces.
• The argument declaration list is a comma separated list of
variable declarations.
• Example of function structure
int diff (int x, int y)/* function header, name and
argument list */
{ //start of function
int z; //declare local variables
z = x – y;
return z;
}//end function body
4
Communication Values
6
Global, Local and Static Variables
Variable Scope
9
Function Parameters
Passing By Value vs By Reference
12