What is a Variable?
Okay, lets get to work. A variable is a location in your computer’s memory, which stores information; it’s like a storage bin. You can put a value into a variable and retrieve that value later. When you declare a variable you always have to show what type of variable is going to be used. For instance the variable can hold a number, a letter, or a whole sentence. To tell the compiler the kind of value you want to store in your variable you must define the type. Here is an example of what I’m talking about.
the letter x can hold an integer value. The int was the type. Don’t flip out if you don’t understand what I’m talking about right now. It will all make sense later on. Right now just remember variables hold values. A declaration of a variable is a statement that gives information about the variable to the compiler. Here is the syntax for variable declaration:
The type is the name of some C++ type, such as int, char, float, double, etc. In the above example, the type was int and the variable was x. To simplify matters, for the time being we will only use the integer type for variables. The integer type can hold values between -2,147,483,648 and 2,147,483,647 on the VC++ 6.0 compiler, which is the current industry standard.
|
Note: some compilers hold less than this. |  |
|
 |
Please Rate this Code:
Comments for: What is a Variable?
Annonymouse User says:
Variable is like a storage bin. |
 |
 |
|
 |
|
 |