C++ program to demonstrate call by reference


// call by reference in c++
#include<iostream.h>
#include<conio.h>
void swap(int * ,int *);
void main()
{
          int a,b;
          cout<<"Enter the value for a and b: ";
          cin>>a>>b;
          swap(&a,&b);
          cout<<"Values after swapping A= "<<a<<" B= "<<b;
          getch();
}
void swap(int *p1,int *p2)
{
          int t;
          t=*p1;
          *p1=*p2;
          *p2=t;
}

c++ progarm to implement call by reference : sample output
C++ program to demonstrate call by reference

1 comment:

Anonymous said...

CPP program to implement call by reference