Data is categorized as either constants or variables and either numeric or non-numeric.
Examples of numeric constants
5 4.5 -7
Examples of nonnumeric constants
“Hello World” “5” “Five” “”
Note: Quotes with nothing, not even a space between them are called a zero-length string or empty string.
A variable is a named storage location (area of memory) that can contain data
that can be modified during program execution. A variable can store only 1 item
of data at any one time.
Programmers often need to store values for later use. For example, you may have
values entered by a user for the number of hours worked and a rate of pay. You
plan to multiply the two values and store the result in memory so you can use it
later. For this you will need a variable.
Every variable has a Data Type. The data type specifies the
kind of data the variable can store. As with constants all programming languages
have at least two kinds of data types.
Different programming languages may have other data types.
When you declare a variable, memory space (dependant on the data type) is
allocated to that variable and the kind of data the variable will hold is
specified.
Each variable has a name that is supplied by the programmer. When the programmer
references that variable name in the program they are accessing the
value stored in the memory location associated with that variable.
The contents of the memory location can change; the name of the memory location
will stay the same.
In addition