Chapter 6 Function
Chapter 6 Function
Function:
A function is defined as a self contained block of
statements that perform a particular task or job.
Syntax:
return_type function_name (argument _list)
{
body of function;
}
category of function on the basis of return type and
argument list
1) no return type no argument list
2) no return type but with argument list
3) return type but no argument list
4) return type with argument list
Output:
2) call by reference:
The address of variable or argument is passed to
the function as argument is known as call by
reference.
Output:
Recursive function:
A recursive function is a function which calls
itself is known as recursive function.
To solve a problem using recursive method, two
conditions must be satisfied. They are:
1) Problem could be written or defined in terms
of its previous result.
2) Problem statement must include a stopping
condition.
Output:
2) Global variables(External):
Global variables are defined outside the function
so that their scope is throughout the program.
The initial value is Zero.
Output:
3) static variables:
Static variables are special case of local variables.
The keyword static is used to declare static
variable.
The initial value is zero.
Output:
4) register variables:
The register storage class is used to define local
variables that should be stored in a register instead
of RAM.
Output: