Wednesday, 14 April 2021

Function declaration or Function prototype

A user defined function has to be developed by the user at the time of writing a program. every function has the  following elements associated with it.

  1. Function declaration 
  2. Function call
  3. Function definition 
  4. Function parameters
  5. Return statement.

Function declaration: Before using any user defined function in your C program, they must be declared. This type of declaration is called function prototype.

A function prototype tells to compiler information such as name of the function, the return value, type of the parameters. More generally a function declaration tell us what a function can do.

The general format to declare a function is

syntax: return-type function-name(argument-list);

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

Function call: function call is a postfix expression. The operand is the function name and operators are parameters list. The general form to call a function is 

Syntax: function-name(argument-list);

Example: sum(a,b);

Function definition: The function definition consist of code of the function. It is made up of two parts: the function header and function body.

Syntax: return-type function-name(argument-list)


                    function body



int sum(int a, int b)


// some line of code here


The function header consists of three parts: return type, function name and parameter list.

 Function parameters: These are input values to a function. C supports two types of arguments: actual parameters and formal parameters.

Return statement: The return statement is used to terminate the execution of a function and return control to the calling function.

A C function may or may not return a value from the function. If you don't have to return any value from the function, use void as return type.

The detail explanation about parameters type and return type can available on upcoming pots.


Post a comment

Note: only a member of this blog may post a comment.

Find Us On Facebook

Contact Us


Email *

Message *

C Programming


C++ Tutorial


Java Tutorial


software engineering


MS Office


Database Management