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();
}
nice post stating is good.
ReplyDeletehttps://www.kellytechno.com/Hyderabad/Course/AI-Training-In-Hyderabad