How to find maximum or minimum using macro in C

1 Answer

0 votes
#include <stdio.h>

#define MAX(x, y) (x > y ? x : y)
#define MIN(x, y) (x < y ? x : y)

int main()
{
    int a = 96, b = 12;

    printf("MAX = %d\n", MAX(a, b));
    printf("MIN = %d\n", MIN(a, b));

    return 0;
}




/*
run:

MAX = 96
MIN = 12

*/

 



answered Apr 18, 2022 by avibootz

Related questions

1 answer 141 views
1 answer 142 views
2 answers 218 views
1 answer 138 views
1 answer 123 views
123 views asked Apr 19, 2022 by avibootz
1 answer 108 views
...