Variable

In mathematics, a variable is a symbol or letter, such as "x" or "y," that represents a value. In algebraic equations, the value of one variable is often dependent on the value of another. For example, in the equation below, y is the "dependent variable" because its value is based on the value assigned to the "independent variable" x.

y = 10 + 2x

The equation above may also be called a function since y is a function of x. If x = 1, then y = 12. If x = 2, then y = 14.

Variables are also used in computer programming to store specific values within a program. They are assigned both a data type as well as a value. For example, a variable of the string data type may contain a value of "sample text" while a variable of the integer data type may contain a value of "11". Some programming languages require variables to be declared before they can be used, while others allow variables to be created on the fly. The data type, if not defined explicitly, is determined based on the initial value given to the variable.

A function within a program may contain multiple variables, each of which may be assigned different values based on the input parameters. Likewise, a variable may also be used to return a specific value as the output of a function. In the Java example below, the variable i is incremented during each iteration of the while loop, and x is returned as the output.

while (i < max)
{
  x = x+10;
  i++;
}

return x;

As the name implies, the value of a variable can change. Variables that store values that do not change are called constants.

Updated May 3, 2012 by Per C.

quizTest Your Knowledge

Which of the following is an emoticon?

A
(heart)
0%
B
n00b
0%
C
^_^
0%
D
1337
0%
Correct! Incorrect!     View the Emoticon definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Variable on this page is an original definition written by the TechTerms.com team. If you would like to reference this page or cite this definition, please use the green citation links above.

The goal of TechTerms.com is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.