1 2 3 4 5 6 7 8 9 10

Function Declarations(ANSI prototype)

type FunctionName ( ParameterDeclarations );

*

For example:
float Work (int x, double y, char* s); float Work (int, double, char*);

The parameters in the prototype are in the order of the function definition (no surprise there).

*

Function Definitions

*

The ANSI style of function definition is:

type FunctionName (ParameterDeclarations) {
<local variable declarations>;
<statements>;
return (<expression>);
}

A return statement is used to supply the value of the function and to give control back to the calling program Formats of the return statement are:

*

*

return (Rvalue);orreturn Rvalue; and
return ;/* used only with voidfunctions */

Although the return can be omitted in that case.

January 22, 1999

Page 4

copyright UoA