DIFINATION-it is a block of code that has a property that it is reusable.it may be executed from many different point in c program.
Name of the function is globaly decleared therefore it can be accesed from anywhere in the program.
Use of functions reduce the complexity of the c program and it gives the return type, function name, passing arguments.All the c program have a function ‘main’.
STRUCTURE OF FUNCTION–-
There are three parts of function.
1.FUNCTION PROTOTYPE
2.FUNCTION CALL
3.FUNCTION DEFINITION
FUNCTION PROTOTYPE–>Function prototype gives the return type ,function name and the data type of the arguments that is to be passed.
Return_type Function_name(data type of arguments);
eg- int fun_name(int , int);
Note-In prototype only the data type is define.And the order of the arguement will do matter.
and the prototype will be define globally.
FUNCTION CALL-> Function call will be define in main.In the call function argument will be pass, according to the reqirment of the program.It will declear the element which is about to pass.
And if we want to return a value from defination then store the value in different variable.
There are tthree different way to passing an argument.
a.Pass by value
b.Pass by reference
c.Passing a array
=>In pass by value:-value of deta type will be pass to a function.
=>In pass by reference:-Address of the data type will be pass.
=>In pass by array:-Name and the size of array will be pass to afunction.
eg- function_name(i , j);
//where iand j are the variables,here when we pass the address of the i and j ,then it will be the pass by reference.
function_name(size , name of the array); // pass by array
FUNCTION DEFINITION–>
it gives the return type ,function name and the passing argument with the data type and the body of the difinition is—-
return_type function _name(passed argument with their data types)
{
statements
—————-
}