Function Prototype Declaration
Function Prototype Declaration is a statement in which programmer describes three information about a function:
- Symbol name of the function
- Return type of the function
- Arguments that will be taken as input
Syntax: <return type> <function name>()<arguments>; Example: int add( int a, int b);
Function Definition
Definition is the actual body/source code of the function. It may contain one or more statements inside it.
Syntax: <return type> <function name>()<arguments> { return ; } Example: int add( int a, int b) { return (a + b); }By default, any C function returns an int value.
add(int a, int b) is same as int add(int a, int b);
If we want the function to return a variable type other than integer, we have to explicitly mention the return type (float or char) before the name of the function during definition and declaration.
A good programming practice is that declaration should be in a header file and definition should be in a source file.
About our authors: Team EQA
You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.