Write a macro that Swaps two numbers. WAP to use it.
#include<iostream>
#define swap(x,y) { x=x+y; y=x-y; x=x-y; }
using namespace std;
void main()
{
int x,y;
system("cls");
cout<<"\n Enter any two numbers : ";
cin>>x>>y;
cout<<"\n\n Before swapping\n x= "<<x<<"\n y= "<<y;
swap(x,y);
cout<<"\n\n After swapping\n x= "<<x<<"\n y= "<<y<<"\n\n";
system("pause");
}
Comments
Post a Comment