Many different types of variables and constants exist in all computer languages. The reason for this diversity is the different types of data each variable or constant can hold. Most of the time, variables and constants hold the following types of data.
- Integers: Integer values are positive or negative numbers without any fractional part, such as 5, 100, 135, -25, and -5123.
- Reals: Real values are positive or negative numbers that include a fractional part, such as 5.14, 7.23, 5.0, 3.14, and -23.78976. Real values are also known as “floats.”
- Booleans: Boolean variables or constants can hold only one of two values: true or false.
- Characters: Characters are alphanumeric values (always enclosed in single or double quotes) such as “Hello Zeus”, ‘I am 25 years old’, or ‘Peter Loves Jane For Ever’. Character values are also known as “strings”!!! (Probably the word “string” makes you visualize something wearable, but unfortunately it’s not. Please keep your dirty precious mind focused on computer science!)
This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!