CALL by REFRENCE: (SWAPING)

SWAPING:  Interchange values means convert one value of variable to another variable value



CALL BY REFRENCE:SWAPING
#include<iostream>
using namespace std;
void swap(int &num1, int &num2);
void main( )
{
int Var n, Var m;
cout<<"Enter two numbers "<<endl;
cin>>Var n;
cin>>Var m;
cout<<"you entered number 1 that is: "<<Var n<<endl;
cout<<"you entered number 2 that is: "<<Var m<<endl;
swap(Var n, Var m);
}


void swap(int &num1, int &num2)
{
int Temp;
Temp = num1;
num1 = num2;
num2 = Temp;
cout<<"After swapping number 1 is "<<num1<<endl;
cout<<"After swapping number 2 is "<<num2<<endl;
}
.......................................................


Run on machine or system to execute:

// take var 1,var 2 instead of var n,var m.