Long Integer / Int Data Type

How is "long int" datatype used in C++?.

Explanation

The "long int" data type is used to represent long integers. The signed range of the "long int" datatype is between -2147483648 to 2147483647 and the unsigned range is between 0 to 4294967295.

Example :



#include <iostream.h>
void main()
{
unsigned long int l = 31356;
signed long int s = -31455;
cout << "Unsigned long integer is:" << l <<'\n';
cout << "Bytes used by unsigned long int is:"<<
sizeof(l) <<'\n';
cout << "signed long integer is:" << s <<'\n';
cout << "Bytes used by signed long int is:" <<
sizeof(s);
}

Result:


Unsigned long integer is:31356
Bytes used by unsigned long int is:4
signed long integer is:-31455
Bytes used by signed long int is:4

In the above example both signed,unsigned values are displayed along with bytes occupied by the "long int" data type.

C++ Tutorial


Ask Questions

Ask Question