how to definition and declarating th function

Function definition and declaration


Function definition format

return-value-type  function-name( parameter-list ) {    declarations and statements }
Function-name: any valid identifier
Return-value-type: data type of the result (default int)
void – indicates that the function returns nothing
Parameter-list: comma separated list, declares parameters
A type must be listed explicitly for each parameter unless, the parameter is of type int

Function definition format (continued)
return-value-type  function-name( parameter-list ) {    declarations and statements }

Declarations and statements: function body (block)

Variables can be declared inside blocks (can be nested)
Functions can not be defined inside other functions
Returning control
If nothing returned
return;
or, until reaches right brace
If something returned
return expression;

Labels: