web analytics

How to declare a function in C or C Plus Plus?

Function declaration : The program or a function that called a function is referred to as the calling function or calling program. The calling program should declare any function that is to be used later in the program. This is known as the function declaration. 

A function declaration consists of four parts. They are,

  1. Function type
  2. Function name
  3. Parameter list
  4. Terminating semicolon

They are coded in the following format :
          Funtion_type   function_name(parameter list);
Points to note :

  1. The parameter list must be separated by commas.
  2. If the function has no formal parameters, the list is written as void.
  3. The return type is optional when the function returns int type data.
  4. When the declared type does not match the types in the function definition compiler will produce an error.
Please follow and like us:
Pin Share
Follow by Email
Scroll to Top