Data Types
Data type is defined as the set of possible values a variable can hold. Data types in C++ can be divided into three categories:
Built-in Data Type
User Defined Data Type
Derived Data Type
Built-in Data Types
The C++ compiler supports all the built-in data types. These data types are also known as standard data types and ae not composed of other data types. For more clarity refer the figure in the attachment:
Data type modifiers
A modifier is used to change the meaning of the basic data type according to the requirement of the program. The modifiers signed, unsigned, long, and short may be applied to basic data types ( integer, character). Long float is not used because it is equivalent to double. Modifiers cannot be used with void type.
Data Types and sizes
Integers
Integer data types (int) are whole numbers in use in C++. the size of integers is 2 bytes. three types of integers are used in C++.
1. Signed / unsigned integers
2. Short integers
3. Long Integers
Signed Integer
A signed integer (signed int) is a positive or negative integer. the range of signed integers is from -32768 to +32767.
Unsigned integer
Unsigned integers do not have negative values. These integers accept only zero and positive values. The size of unsigned integers is 2 bytes. They can range from 0 to 655357.
Short integers
Short integers have a small range of values. The range of short integers is from -128 to 127. The size is 1 byte.
Long intergers
The range of long integers is from -2^32 to 2^32. the size is 4 bytes.
Examples of valid integers: 439, 11, 20495, -126
Examples of invalid integers : 961.21 (float), 4,325 (comma is not allowed), 81 562 (blank space within a number is not allowed).