Functions in C

Functions in C :

  • The function in c,   are the basic building block in c.
  • Function definition : Function is a set of statement in block which is used to perform specific tasks.
  • Function in c is the block of code with specific task.
  • In c , First we have to declare the function  after that we define the function then we call the function to execute function.
  • Function structure in c :

Syntax :

<return type> function _name (parameters){


  1.   Return type: return type in function means value return by the function,we write type of value which function returns that is int, float etc.If function does not return anything we mention void as return type of function.
  2. function name : its the name of the function.
  3. parameter list : The parameters are the values which we want to pass to the function.The function accept any number of parameters. if we do not want to pass value to function we mention the void as the function parameters.
  • Function Declaration :  Before using the function we declare the function.function declaration as follow :


<return type> function_name (parameters list);

example:    int function1(void);

  • Function Definition :  after declaration we define the function.


<return type> function_name (parameters list)




example: int function1(void){



  •   Function call :  To execute the code of function we have to call to the function.we call function as follow


example :



12345678910111213141516171819202122232425262728293031323334353637383940// program to illustrate the function in detail.#include<stdio.h>#include<conio.h>//function add(int,int);    //function with parameter and return typevoid display(void);   //function with no parameter and no return typevoid main(){int a,b,c;a=10;b=10;printf(“calling function:\n”);c=add(a,b);  //function callprintf(“after function call:\n”);printf(“Addition = %d”,c);display(); //function callgetch();}int add(int a,int b){int c=a+b;return c;}void display(void){  printf(“\nfunction with no parameter and no return type”);}output:calling function:after function call:Addition = 20function with no parameter and no return type


Leave a Comment

Your email address will not be published.