Write a C program to define a macro MAX which gives the maximum of two numbers. Use this macro to find the maximum of three numbers.

 C File =>


/* Write a C program to define a macro MAX which gives the maximum of two numbers. Use this macro to find the maximum of  three numbers. */


#include<stdio.h>
#define MAX(a,b) (a>b?a:b)
int main() {
int n1,n2,n3,max,max1;
printf("\n Enter three numbers : ");
scanf("%d%d%d",&n1,&n2,&n3);
max=MAX(n1,n2);
max1=MAX(max,n3);
printf("\n Maximum of three numbers = %d",max1);
return 0;
}

Comments

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.