The C language contains 5 basic data types: Void, integer, float, double, and Char.
| Type |
Describe |
| void |
Empty type |
| Int |
Integral type |
| Float |
Floating-point types |
| Double |
Double-precision floating-point type |
| Char |
Character type |
C + + defines two additional basic data types: BOOL and wchar_t.
| Type |
Describe |
| bool |
Boolean type with a value of true or False |
| wchar_t |
Wide character type |
Type modifiers
Some basic data types can be modified by signed, unsigned, short, and long. When the type modifier is used alone, the default type is int. The following table is all the data types that can occur:
| bool |
| Char |
| unsigned char |
| Signed Char |
| Int |
| unsigned int |
| Signed int |
| Short int |
| unsigned short int |
| Signed Short int |
| Long int |
| Signed Long int |
| unsigned long int |
| Float |
| Double |
| Long double |
| wchar_t |
Type size and presentation range
The size of the base data type and the range of data that can be represented are related to the compiler and the hardware platform. The "Cfloat" (or "float.h") header file often defines the maximum and minimum values of the data that the base data type can represent. You can also use sizeof to get the size of the type (the number of bytes). However, many platforms use standard sizes for some data types, such as. int and float typically occupy 32 bits, char occupies 8 bits, and double usually occupies 64 bits. Bools are usually implemented in 8 bits.