Function Prototype
A
function prototype is simply the declaration of a function that specifies
function’s name, parameters and return type. It’s doesn’t contain function
body.
A
function prototype gives information to the compiler that the function may later
be used in the program.
Syntax of function prototype
returtype functionname(type1 agrugment1,type2
argument2….);
The
function prototype which provides the following information to the compiler.
1.
name of function is addnumber()
2.
return type function is int()
3.
two argument of type int() are
passed to the function.
The
function prototype is not needed if user-define function is defined before the main() function.
Calling a function
Control
of the function is transferred to the
user-defined function by calling it.
Syntax of function call
functionname(argument1,
argument2….);
Passing argument to a function
The
parameters a and b accepts the passed argument in the function definition.
These
argument are called formal parameters of
the function.
Return Statement
The
return statement terminates the execution of a function and return a value of
the calling function. The program control is transferred to the calling
function after the return statements.
Fig: return statement |
Syntax of return statement
return(expression);
Example:
return a;
No comments:
Post a Comment