Functions with Pass by Variable

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

Function Declaration

Function declaration is done above the main function definition. The function declaration is just giving the name and specifying the parameters. The syntax as follows.

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);

NOTe: specifying parameter name is not mandatory.

Function Call

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.

Function Definition

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
  1. Functions without return type and without parameters
  2. Functions without return type and with parameters
  3. Functions with return type and without parameters
  4. Functions with return type and with parameters
Based on parameter type there are 3 types of functions in C. Those are
  1. Functions with Pass By values
  2. Functions with Pass By variables
  3. Functions with Pass By address or reference