Sunday, February 15, 2015

C program to swap two numbers using macros

C++ program to swap two numbers using macros

#include<iostream.h>
#include<conio.h>

#define SWAP(a,b) {int temp; temp=a; a=b; b=temp;}

void main()
{
clrscr();
int x,y;
cout<<"Enter two numbers:";
cin>>x>>y;

cout<<"x="<<x<<" y="<<y;
SWAP(x,y);
cout<<"
x="<<x<<" y="<<y;

getch();
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.