#include<iostream.h>
#include<conio.h>
class pointer
{
int *a;
int *b;
public:
void swap();
};
void
pointer::swap()
{
int i,j;
cout<<"enter
the value of a "<<endl;
cin>>i;
cout<<"enter
the value of b"<<endl;
cin>>j;
a=&i;
b=&j;
int *temp;
*temp=*a;
*a=*b;
*b=*temp;
cout<<"AFTER
SWAPPING USING POINTERS"<<endl;
cout<<"a
is "<<*a<<endl;
cout<<"b
is "<<*b<<endl;
}
void main()
{
clrscr();
pointer obj;
obj.swap();
getch();
}
Comments
Post a Comment