Program -
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int x,y,*p1,*p2;
void
exchange(int,int);
cout<<"\n
enter the value of x and y:";
cin>>x>>y;
p1=&x;
p2=&y;
cout<<"\n
before exchange x="<<x<<"and
y="<<y<<endl;
exchange(p1,p2);
cout<<"\n
after the exchange x="<<*p1<<"and y="<<*p2;
getche();
}
void
exchange(int*p3,int*p4)
{
int temp1;
temp1=*p3;
*p3=*p4;
*p4=temp1;
return;
}
Output -
enter the value of
x and y: 5 10
before exchange
x=5and y=10
after exchange
x=10 and y =5
0 comments:
Post a Comment