SWAPING........
#include <iostream>
using namespace std;
int main()
{
int a=10,b=20;
cout <<a<<" "<<b<<endl;
a+=b-=a=b-a;
cout <<a<<" "<<b<<endl;
a/=b=(a=a*b)/b;
cout <<a<<" "<<b<<endl;
a^=b^=a^=b;
cout <<a<<" "<<b<<endl;
a=(b=(a=b^a)^b)^a;
cout <<a<<" "<<b<<endl;
b=a+b-(a=b);
cout <<a<<" "<<b<<endl;
a=a^b;
b=a^b;
a=a^b;
cout <<a<<" "<<b<<endl;
a=a+b;
b=a-b;
a=a-b;
cout <<a<<" "<<b<<endl;
int temp=a;
a=b;
b=temp;
cout <<a<<" "<<b<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int a=10,b=20;
cout <<a<<" "<<b<<endl;
a+=b-=a=b-a;
cout <<a<<" "<<b<<endl;
a/=b=(a=a*b)/b;
cout <<a<<" "<<b<<endl;
a^=b^=a^=b;
cout <<a<<" "<<b<<endl;
a=(b=(a=b^a)^b)^a;
cout <<a<<" "<<b<<endl;
b=a+b-(a=b);
cout <<a<<" "<<b<<endl;
a=a^b;
b=a^b;
a=a^b;
cout <<a<<" "<<b<<endl;
a=a+b;
b=a-b;
a=a-b;
cout <<a<<" "<<b<<endl;
int temp=a;
a=b;
b=temp;
cout <<a<<" "<<b<<endl;
return 0;
}
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......