Function Prototype

Function Prototyping

Function prototyping is telling the compiler the name of the function, return data type including void, number of parameter it receives and data type of the parameter and the order in which it is supplied. The compiler uses this information at runtime to check the correct type of parameter is supplied in right orders.

There can be function that may not return any value. Also there can be function, which do not collect any parameters. Consider the following function prototype:

float MutiplyDivide(int, int, int);

It tells the compiler that function MultiplyDivide takes three integers as parameters and returns a float. When you implement a function you actually specify the parameter names like shown below:

float MutiplyDivide(int param1, int param2, int param3)

{

            float k;

            //Some Loagic Here

 

            return k;

}

You should also note that the compiler will not restrict you to name parameters in the function prototype. The below prototype is absolutely acceptable:

float MutiplyDivide(int m1, int m2, int d1);