INT_MAX in C/C++
INT_MAX is a macro that specifies that an integer variable cannot store any value beyond this limit. It represents the maximum value of the upper limit of the integer data type in C/C++.
The value of INT_MAX is:
- INT_MAX = 2147483647 (for 32-bit Integers)
- INT_MAX = 9,223,372,036,854,775,807 (for 64-bit Integers)
INT_MAX and INT_MIN in C/C++ and Applications
Most of the time, in competitive programming, there is a need to assign the variable, the maximum or minimum value that data type can hold, but remembering such a large and precise number comes out to be a difficult job. Therefore, C/C++ has certain macros to represent these numbers, so that these can be directly assigned to the variable without actually typing the whole number.
C/C++ provides two such macros namely INT_MAX and INT_MIN that represents the integer limits. Depending upon the compiler and C++ standard, you may be required to include the header file <limits.h> or <climits> in your C or C++ source code respectively. So it is advisable to include this header file for using the INT_MAX, and INT_MIN macros. For further reading on this header file, refer to this article.
Contact Us