data types

what is the difference between int and long int even when both occupy 4 bytes??
They don't necessarily have the same size on all systems. sizeof(long) is always >= sizeof(int).
They might hold the same amount of bytes, but long, can hold more digits than int.
how can a variable hold more digits when both have the same amount of bytes??
It can't.
All that the C++ standard guarantees is that short <= int <= long <= long long. Therefore, anything that fits into a short, can fit into the other three, and so on. Most 32 bit systems are designed that int and long are both 4 bytes, while long long is of 8 bytes, but again, this isn't guaranteed.

Read this for more information: http://www.cplusplus.com/reference/climits/
Topic archived. No new replies allowed.