It's possible your implementation of <iostream> (or another header) includes <limits.h> or <climits> somewhere.
This is not required by the standard though, and won't work for all compilers.
In general, always #include the header that defines the function/type/macro you need, to ensure portability between different compilers. Worst case scenario is that it skips the header file the 2nd time it encounters it because of proper header guards, no damage done.
Thanks. I am using a dev c++ compiler. In that climits is not required for these scenarios. Program is giving output even without using climits library.
@abcdef123
It appears you didn't even read Ganado's answer. Let me put this as simply as possible:
1. You create homework that compiles on your machine
2. You submit homework to professor, who will be grading your efforts
3. Your homework does not compile on your professor's machine
4. You receive a 'D' for minimal effort
Here's another scenario:
1. You create application that compiles on your machine
2. You commit changes to work computer, so that you can get paid
3. Your application fails to compile on client's machine and causes late-night roll back meeting involving at least three engineers
4. You get fired
The takeaway: If you use a construct, include its header.