Wednesday, November 26, 2008

Addition in C using a macro

#include
#include

#define add(a,b) a+b //defining the macro

void main()
{

int x,y,sum;
clrscr();
printf("enter the 2 numbers for addition\n");
scanf("%d\n%d",&x,&y);
sum = add(x,y); //using it here
printf("\ntheir sum is %d",sum);
getch();

}

No comments: