How to get the maximum / minimum value of an integer in the C language

4

Speak up! Is there a function in language C that takes the maximum / minimum value of an integer?

    
asked by anonymous 06.03.2017 / 05:56

1 answer

6

There is no function, but there are macros defined in the limits.h header of the standard in> C. Example code that prints the minimum and maximum values of an integer:

#include <stdio.h>
#include <limits.h>

int main() {

   printf("Menor valor de um inteiro: %d\n", INT_MIN);
   printf("Maior valor de um inteiro: %d\n", INT_MAX);

   return(0);
}

See running on Ideone .

    
06.03.2017 / 13:26