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 227 views
2 answers 331 views
1 answer 240 views
1 answer 233 views
1 answer 199 views
199 views asked Apr 19, 2022 by avibootz
1 answer 190 views
...