What is macro? Define a macro to compute maximum of two arguments passed to it.
A macro is a fragment of code which has been given a name.
Whenever the name is used, it is replaced by the contents of the macro. There
are two kinds of macros. They differ mostly in what they look like when they
are used. Object-like macros resemble data objects when used, function-like macros
resemble function calls.
#include <stdio.h>
#define MAX(x,y) ((x>y)?x:y)
/*=======================
Girfa Student Help
Macro Demo
========================*/
void main()
{
int a, b, max;
printf("Enter
first number: ");
scanf("%d", &a);
printf("Enter
second number: ");
scanf("%d", &b);
max = MAX(a, b);
printf("Maximum
number is: %d\n", max);
}
No comments:
Post a Comment