Program code:
#include<iostream>
using namespace std;
int main()
{
int x , y , z , *a , *b , *c ;
cout<<"Enter value of x : ";
cin>>x;
cout<<"Enter value of y : ";
cin>>y;
cout<<"Before swapping x : "<<x;
cout<<"\nBefore swapping y : "<<y;
a = &x;
b = &y;
c = &z;
*c = *a;
*a = *b;
*b = *c;
cout<<"\nAfter swapping x : "<<x;
cout<<"\nAfter swapping y : "<<y;
return 0;
}
Output:
.exe file |
No comments:
Post a Comment