Return
To COSI 216 - HOME
Return
to Handout
Return to Course Outline
Return to Chapter Seven
Definition of Function:
What is a function?
-
A set of instructions.
-
Data pass through FUNCTION and return data to caller.
Why do you use function?
-
To design a program into modules.
-
To peform the same instructions.
-
To create library of reusable tools.
Structure of program:
Function Prototypes
// This lets the compiler check whether callers have the number of parameters
// same as the number of
parameters that fumction has. Also,
// the compiler will check each parameter's data type. The compiler
will see
// that the data types are matched from calling to called.
void main()
{
call functions
}
Definitions of functions
//The difference between function prototypes and function headers: example:
// Header: float
Average(float
X, float Y, float Z)
// Prototype: float
Average(float
X, float Y, float Z);
// The only difference is ' ; ' .
Return
to Handout