C++ Functions Parameters

 

Functions Parameters

A function receives information that is passed to them as a parameter. Parameters act as variables inside the function.

Parameters are specified collectively inside the parentheses after the function name. parameters inside the parentheses are comma separated.

 

We have different names for different parameters.

 

Formal Parameters

So, the variable which is declared in the function is called a formal parameter or simply, a parameter. For example, variables a and b are formal parameters.

int sum(int a, int b){
   //function body
}

 

Actual Parameters


The values which are passed to the function are called actual parameters or simply, arguments. For example, the values num1 and num2 are arguments.


int sum(int a, int b);
 
int main()
{
    int num1 = 5;
    int num2 = 6;
    sum(num1, num2);//actual parameters
}


A function doesn't need to have parameters or it should necessarily return some value.