You are on page 1of 1

Functions

A function is a self contained program segments that carries out a specific, well
defined task. When the arguments are declared within the parenthesis, each and
every argument has to be defined individually, irrespective of whether they are of
same type.
Return statement: the return statement is used to return from a function.
Eg: return(expression);
Two purposes of return statement :
1. It immediately transfers the control from the function backt to the
calling program.
2. Whatever is inside the parenthesis following the return is return
Invoking a function:
A function can be invoked from the main program by simply calling it by using
its name,including the parenthesis, which follow the name. the parenthesis are
necessary so that the compiler knows that a function and not a variable is being
referred to.a semicolon is not used in the end. The absence of the semi colon
indicates to the compiler that a function is beoing defined and not called.
Function declaration:

You might also like