C++ language is rich in its data type. It is the storage format to store data. The variety of data types available allows the programmer to select the type appropriate to the needs of the application as well as the machine.
C++ Support three type of data types:-
Primary (or fundamental) data type
Derived data type
User-defined data type
Primary (or fundamental) data types
In this tutorial, primary data type and their extensions are discussed. Derived and user-defined datatype are discussed when array, pointer, functions are encountered.
An integer is a whole number with a range of values supported by the particular compiler. Generally, integers occupy one word of storage, and since the word sizes of compiler vary(typically 16 bit,32, and 64 bit). If we use 16-bit word length then the size of an integer value is limited to range -32768 to +32767.
In order to provide some control over the range of number and storage space, C++ has two classes of integer, Signed and unsigned.
Floating point (or real) numbers are stored in 32 bits (on all 16 bit and 32-bit compilers) with 6 digits of precision. Floating-point numbers are defined in C++ by the keyword float. when the accuracy provided by a float number is not fulfilled, double can be used to define the number. A double data type number uses 64 bits giving a precision of 14 digits. To extend the precision further, we may use long.
The character can be defined as Character type data. The qualifier Signed or Unsigned may be explicitly applied to char While Signed char have a value from -128 to 127, Unsigned chars have value 0 to 255.