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.

Author: Tanmay Chakrabarty

Tanmay Chakrabarty is a former CSE student, currently working as a Senior Software Engineer with 5+ years of experience in the field of Web Application development in PHP+MySQL platform with strong skills in Javascript, JQuery, JQuery UI and CSS. He tries to write notes every week but fails due to heavy loads of duty.

Recommended Recommends


Contact Us