C++ Programming Blog

 
 
 
#include<iostream.h>
#include<conio.h>
void swap (int &a, int &b)
{
    /* &a and &b are reference variables */
    int temp;
    temp=a;
    a=b;
    b=temp;
}

main()
{
    clrscr();
    int i=5,j=10;
    cout<<\"Before swapping I = \"<<i<<\" J = \"<<j<<endl;
    swap(i,j);
    cout<<\"After swapping I = \"<<i<<\" J = \"<<j<<endl;
}

 
 
Didn't find what you were looking for? Find more on Program of swapping numbers by call by reference