In C++, data types can be classified into various categories. This is as shown in the figure below:
Data Type | Size | Range |
---|---|---|
char | 1 byte | -127 to 127 or 0 to 255 |
unsigned char | 1 byte | 0 to 255 |
signed char | 1 byte | -127 to 127 |
int | 4 byte | -2147483648 to 2147483647 |
unsigned int | 4 bytes | 0 to 4294967295 |
signed int | 4 bytes | -2147483648 to 2147483647 |
short int | 2 bytes | -32768 to 32767 |
unsigned short int | Range | 0 to 65,535 |
signed short int | Range | -32768 to 32767 |
long int | 4 bytes | -2,147,483,648 to 2,147,483,647 |
signed long int | 4 bytes | Same as long int |
unsigned long int | 4 bytes | 0 to 4,294,967,295 |
float | 4 bytes | +/- 3.4e +/- 38 7digits |
double | 8 bytes | +/- 1.7e +/- 308 15digits |
long double | 8 bytes | +/- 1.7e +/- 308 15digits |
wchar_t | 2 or 4 bytes | 1 wide character |