Variables in C++ are divided into three major types.
- Integer
- Floating-point numbers
- Characters
Integers are whole numbers such as 5, 100, 10000. They are 4 bytes long and they range from 0 to +4,294,967,295.
A subset of an integer is the Unsigned Integer. An unsigned integer has a shorter range and is 2 bytes long. The range of an unsigned integer is 0 to +65,535.
int number 1 = 10000;
unsigned int number2 = 256;
Floating-point numbers are basically numbers that have decimal points such as 0.75, 10.5, 1000.90. They are 4 bytes long and have a range from 3.4 x 10-38
to 3.4 x 10+38.
float num = 100.501, num1 = 1.21;
Characters are single letters like a, z, k, and so on. Characters are 1-byte long and they range -127 to 128.
char nam = ‘k’, nam2 = ‘e’, nam3=’v’;