Variable

A **variable** is a special type of amount or quantity with an unknown value. The opposite of a variable (that is, a known value) is called a constant.

## Variables in math
In mathematics, a variable is usually given a letter, such as *x* or *y*. Other letters are often used for particular kinds of variable:

* The letters *m*, *n*, *p*, *q* are often used as variables for integers.
* The letters *a*, *b* and *c* are often used as coefficients of functions.
* The letters *i*, *j*, *k* are often used as indices of summation.
* The letter *t* is often used as a variable for time.
* The letter *z* is often used as a variable for complex numbers.
* The letters *x*, *y*, *z* are often used as variables for a single location in 3D space. They're often thought of as width, height, and depth respectively.

Most letters are used in equations to show numbers that are unknown (an exception is *e*, which is a constant). Using a type of math called algebra, one can find the value of the variable.

Any number cannot change its value. This is true whether the number is rational (such as -8.625) or irrational (such as 2√3, which is 2 multiplied by the square root of 3), or whether the number is real (such as \pi) or imaginary (such as i).

Variables are also common in science, where they usually represent physical properties that do not stay the same. For example, if a person stands 5 feet away from a building, the *distance* variable compared to the building does not change over time. 5 feet (1.52 meters) is called a *fixed amount*, which is the opposite of a variable amount. But if a person walks away from the building, the distance variable compared to the building is increasing. So it does not have the same value, and we cannot use the same number for it, as the distance might be 1 foot now, but 2 feet (0.61 meters) a second later.

## Variables in computer science
In computer science, a variable is a value in a program that can change. It does not have to be a number. It can be a string (text value), a date, an amount of money, an object such as a picture, or simply null (which means it has no content). The value that is stored in a variable can change the behavior of a program when it is run. Because of this, variables are commonly used to store input and output values.

Each programming language works differently with variables. Most of them allow any character string that is not "reserved" (that is, has a special meaning to the language) to be the name of the variable. It is good in computer programming to use names that tell what will be stored in the variable (such as "person", "age", "total", and so on rather than "a", "b", "c", ...).

Also, some languages like C and Java require the data type of the variable (that is, the *kind* of content that will be stored in it) to be declared (written) when the variable is created. Others, like Python and Visual Basic, do not have this rule, which allows the ***type*** (not just value!) of variable to be changed when a new value is stored in it.

If the value is *not* a variable (i.e., if the value can't be changed), then the value is called either a "literal" or a "constant", depending on context.

For example, 
* `"Hello world!"` is a literal (with type `string`).
* `5` and `const int myFavoriteNumber = 5;` are each a constant (with type `int`).

## Related pages 
* Dependent and independent variables
* Explanatory variable

## References