/    /  Passing Arguments/Parameters

v) Passing Arguments/Parameters:

 

Parameters are the means of communication between the function calling and therefore the called functions (function definition).

Parameters  are further classified into 2 types:

  1. Actual Parameters
  2. Formal Parameters

 

Actual Parameters:

 

The Actual parameters are often referred to as arguments that are laid out in the call.

 

Syntax:

 

function_name(Actual_Parameter1, Actual_Parameter2,… Actual_ParameterN);

 

Example:

 

main( )
{
 void compute(int , int);
 ------;
compute(a , b); /* a & b are called Actual
 Parameters */
 -------;
}

 

Formal Parameters:

 

The Formal Parameters (commonly called Parameters) are the parameters given within the function definition.

 

Syntax:

 

return_typefunction_name(datatype Forml_Parmtr1,..,…,… datatype Forml_ParmtrN)
{
Statement1;
Statement2;
}

 

Example 1:

 

void compute (int x, int y)/* x&y are called Formal Parameters */
{
int z;
z = x + y ;
printf(“%d”, z);
}

 

Example 2:

 

int compute (int x, int y)/* x&y are called Formal Parameters */
{
int z ;
z = x + y ;
return z;
}

 

The following conditions should be satisfied for a function call:

a. The number of arguments within the function declaration, function call, and performance definition must be equivalent.
b. The info sort of each of the arguments within the call should be because equivalent the corresponding parameter within the function declaration statement, i.e., the order during which we specify the arguments while calling the function must be equivalent because the order during which the parameters are specified: however, the names of the arguments within the call and therefore the names of parameters within the function definition are unrelated. they will be equivalent or different.