What is difference between int and long ?

in c or c++ int and long have same size then what is main difference between long and int?

Some compilers actually have long as 64 bit. The thing is, size of long is compiler dependent. Sometimes its 32 bit, sometimes 64 bit. But in most cases (esp. online compilers) you will encounter long being 32 bit.

Its better to go with long long which is a sure 64 bit to avoid unnecessary errors.

1 Like

A simple google search gave me this link: https://stackoverflow.com/questions/18971732/what-is-the-difference-between-long-long-long-long-int-and-long-long-i

1 Like

The storage capacity. An old-style compiler could allocate e.g. 16 bits of storage for an int and 32 for a long. Actual sizes vary between compilers. If you are going to use very large numbers,use long. Hope this clears.

1 Like