How to swap two numbers using macros in C++ program

CWC
0 Min Read

How to swap two numbers using macros in C++ program

#include
#define SWAP(a,b)
{
int temp;
temp=a; a=b; b=temp;
}
using namespace std;
int main()
{
int x,y;
cout<<"Enter two numbers:"; cin>>x>>y;
cout<<"x="<<x<<"
y="<<y;
SWAP(x,y);
cout<<"\nx="<<x<<"
y="<<y; return 0;
}

 

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version