Here a and b are two no. and we are swapping them.It means we are interchanging the values of a and b.
//
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int *a,*b,*c,p,q;
cout<<"enter 2 nos.=";
cin>>p>>q;
a=&p;
b=&q;
*c=*a;
*a=*b;
*b=*c;
cout<<"swapping nos.="<<*a<<'\n'<<*c<<'\n';
getch();
}
OUTPUT
enter 2 nos.=7
5
swapping nos.=5
7
Comments :
Post a Comment