Parameter passed by value:


When we call a function with parameter we pass the copies of their values.
For example

Int x=2, y= 3, z;
z= addition (x,y);
What we did that we pass the value of x and y ( i.e. 2 and 3 )to our desired function.

Parameter passed by reference:

Sponsored Links


In parameter passed by reference, the first thing is that in the declaration of our function the type of each parameter was followed by an ampersand sign (&). This ampersand is what specifies that their corresponding arguments are to be passed by reference instead of by value. When a variable is passed by reference we are not passing a copy of its value, but we are somehow passing the variable itself to the function and any modification that we do to the local variables will have an effect in their counterpart variables passed as arguments in the call to the function.
Example

Void addition (int & a, int & b, int & c)
{
a * = 1;
b* = 2;
c* = 3;
}

Now when we call the function

int x=5, y=3, z=2;
addition (x, y, z);

Here x, y, z will be passed by reference to our original addition function.