C++ Data Types and Sizes

C++ supports a wide variety of data types. C++ supports the following classes of data types:

  • Primary (Fundamental) data types
  • Derived data types
  • User-defined data types
C++ data type
C++ data types

C++ language supports the following basic data types.

  • char : A single byte that can hold one character at a time.
  • int : An integer
  • float : A single-precision floating-point number
  • double : A double-precision floating-point number

Qualifier : A qualifier alters the characteristics such as the size or sign of the data types. The qualifiers the alters the size are short and long. These qualifiers are applicable to integers, and yield two or more types:

  • short int : Integer represented by 16 bits, irrespective of machine type.
  • long int : Integer represented by 32 bits, irrespective of machine type.

Data types and their sizes

Data TypeData Size (bytes)Minimum ValueMaximum Value
int2 (16 bit compiler)
4 (32 bit compiler)
long double10-3.4E-49321.1E+4932

The qualifier long can also be used along with double-precision floating point type: long double- an extended precision floating point number. Note: the sign qualifiers are signed and unsigned. The sign qualifiers are applicable to the integer data types such as : (int, short, int, and long int) resulting in six additional data types given below:

  • signed short int
  • unsigned short int
  • signed int
  • unsigned int
  • signed long int
  • unsigned long int

Qualifiers are also applicable to char data type as under:

  • signed char
  • unsigned char

NOTE: Size qualifiers (short and long) cannot be applied to the char and float data type and sign qualifiers (signed and unsigned) cannot be applied to float, double, and long double.