Write a C program to define a macro that can calculate the greater of two of its arguments. Use this macro to calculate the
greatest of 4 integers.
#include <stdio.h> #define MAX(x,y) ((x>y)?x:y) int 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); return 0; }
Output
Enter first number: 100 Enter second number: 200 Maximum number is: 200
No comments:
Post a Comment