Wednesday 11 February 2015

C++ program to illustrate the concept of call by reference

C++ program to illustrate the concept of call by reference

#include<iostream.h>
#include<conio.h>
void swap (int &a, int &b)
{
    
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;
}

No comments:

Post a Comment