What is a function prototype?

In the portion of program, where user defines variable, functions can be declared or defined using following syntax :

data-type name of function (datatype 1 arg1, datatype 2 arg 2,datatype n arg n);

where arg 1, arg 2, .......arg n are arguments of this function and datatype 1 datatype are data types of these individual arguments. Function declaration written in its fashion are called function prototype.

Ex.
int fort (int n);
int ncr (int n, int r);
float ncr (int n, int r);


The data type written before name of the function is the type of result the function returns. The use of function prototype is not mandatory in C. Function prototype are desirable, because they further facilitate error checking between the call to a function and the corresponding function definition.

When the function is called, the name of the actual arguments need not be the same as the names shown in the declaration. However, the data types of the actual arguments must conform to the data types of the arguments within the declaration.

Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!