C Programming Function Calling Types



C Programming – Types of Function Calling

There are different types of function calling. Depending on the number of parameters it can accept , function can be classified into following 4 types –

Function TypeParameterReturn Value
Type 1Accepting ParameterReturning Value
Type 2Accepting ParameterNot Returning Value
Type 3Not Accepting ParameterReturning Value
Type 4Not Accepting ParameterNot Returning Value

Let us Consider all types of functions one by one –

Type 1 : Accepting Parameter and Returning Value

Above type of method is written like this –

int add(int i, int j)
{
  return i + j;
}

and Called like this –

int answer = sum(2,3);

We need to assign the function call to any of the variable since we need to capture returned value.

Type 2 : Accepting Parameter and Not Returning Value

Above type of method is written like this –

void add(int i, int j)
{
  printf("%d",i+j);
}

above method can be called using following syntax –

sum(2,3);

Type 3 : Not Accepting Parameter but Returning Value

Above type of method is written like this –

int add()
{
  int i, int j;
  i = 10;
  j = 20;
  return i + j;
}

called using following syntax –

result = add();

Type 4 : Not Accepting Parameter and Not Returning Value

Above type of method is written like this –

void add()
{
  int i, int j;
  i = 10;
  j = 20;
  printf("Result : %d",i+j);;
}

and called like this –

add();

Tutorials based on Types of function –

  1. No argument and no return value
  2. C Function Arguments & No Return Value
  3. C Function Arguments & Return Value