Here is the code You can use to swap values of two variables using Pointer Method
#include<iostream.h>
#include<conio.h>
void main()
{clrscr();
int x,y;
int *p1,*p2,*p3;
cout<<"ENTERS THE VALUES FOR x= ";
cin>>x;
cout<<"\nENTERS THE VALUES FOR y= ";
cin>>y;
p1=&x;
p2=&y;
p3=p1;
p1=p2;
p2=p3;
cout<<"THE VALUES AFTER SWAPPING ARE \nx= "<<*p1<<"\ny= "<<*p2;
getch();
}
1 comments:
nice post stating is good.
https://www.kellytechno.com/Hyderabad/Course/AI-Training-In-Hyderabad
Post a Comment