When we pass value of a variable as an argument from the caller function to the function definition, it is called as call by value or passing by value.
swap(a,b); //caller function with actual arguments
.
.
.
swap(int x, int y) //function definition with formal arguments
{
//function body
}
When function does not need to alter the values of the original variables in the calling function or program.
Original values of a:1, b:2
Swaped values in swap function a:2, b:1
After swaping the values of a:1, b:2
Remember Variable name of actual and formal arguments should not be same. |