Function is collection of instructions used to do specific task. Every c program contains at least one
function that is main function. The function can be identified with a name followed by parenthesis.
Function consists of three paarts those are
1. Function Declaration
2. Function Call
3. Function Definition
return type function name(parameters list);
In the above syntax return type indicates the return value type of the function after successful execution of
the function. If nothing is returned then we specify void or else depending upon type of value we may use int,
float, double, char or arrays or structures.
Function name is a identifier with which we identify the name of the function. All the rules which are applicable
for creation of identifier are applicable for function identifier too.
Parameters are the variable defined in the function declarion. These are the variable which are used to receive the
arguments passed when function is called. The parameters list is optional it means functions may have parameters or
may not have. Each parameter specified along with data type. Example Function declaration is given below
void addition();
void multiple(int a, int b);
int mod(int n1, int n2);
float average(int sum, int count);
float simple(int,int,float);
If a function is declared and if it is defined but if it is not called it will not be executed. If it is not executed there is no use of creation of functions. Function call is just specifying the name of the function along with the function parameters where ever we want the function. We shoud not specify the return type.
Actual implementation of the function is called as function definition.
Based on return type and parameters there are 4 types of functions in C. Those are