Function Prototype Declaration: Function Prototype Declaration is a statement in which programmer describes three information about a function:

  1. Symbol name of the function
  2. Return type of the function
  3. Arguments that will be taken as input
Syntax:
<return type> <function name>()<arguments>;

Example:
int add( int a, int b);

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.

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

struct pack padding, size of a structure, bit fields, l-value, struct and array, function declaration and definition, calling conventions, calling convention of C,C++ and PASCAL, library function linking, call-by-value and call-by-reference,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan