On Variable Values
Values refer to the information stored in the variable (location in memory)
Variables can take on different types of values
- Whole numbers or integers: 2, -9, 1048576
- Character sequences or strings: “2”, “&^%$#@”, “ ”
- Decimal numbers or doubles: 2.0, 3.14159, -999.99
In most programming languages, each variable can only hold one type of value
- So the computer will know how much memory will be needed to store the value (e.g., integer vs. double)
- To allow the computer to help detect errors in the code (e.g., when the program tries to put the wrong sort of value in a variable the programmer receives an error message)