PROGRAM FOR CALL BY REFERENCE

//call by reference
#include<iostream.h>
#include<conio.h>
void main()
{
  void swap(int &,int &);
  int a,b;
  clrscr();
  cout<<"enter 2 numbers:";
  cin>>a>>b;
  swap(a,b);
  cout<<"\na="<<a<<"\nb="<<b;
  getch();
}
  void swap(int &x,int &y)
  {
    x=x+y;
    y=x-y;
    x=x-y;
  }

Comments

Popular Posts