BASIC HELP

Can anyone please tell me what is the difference between the properties of INT_MAX and LONG_MAX .
In this code CodeChef: Practical coding for everyone if i use INT_MAX it gives wrong answer , but on LONG_MAX it gives correct . What i know is both have same value then why such behaviour ?

[simon@simon-laptop][20:37:29]
[~/devel/hackerrank/otherpeoples]>cat blah30.cpp 
#include <iostream>
#include <climits>
using namespace std;

int main()
{
    cout << "INT_MAX:" << INT_MAX << endl;
    cout << "LONG_MAX:" << LONG_MAX << endl;
}


[simon@simon-laptop][20:37:33]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling blah30.cpp
+ g++ -std=c++14 blah30.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
+ set +x
Successful
[simon@simon-laptop][20:37:35]
[~/devel/hackerrank/otherpeoples]>./a.out 
INT_MAX:2147483647
LONG_MAX:9223372036854775807

Edit:

They might be the same on a 32-bit OS, though (like my Raspbian install).

1 Like

Thank you so much .

1 Like