Info logo
Encyclopedia

  

Variable

Home :: Up
Google
www.fastload.org

Variable

A variable is something that is subject to change. In computer science and mathematics, it denotes a name that is used to represent an unknown value or quantity. Variables are used in open sentences. For instance, in the formula: x + 1 = 5, x is a variable which represents an "unknown" number. In mathematics, variables are usually represented by letters of the Roman alphabet, but are also represented by letters of other alphabets; as well as various other symbols. In computer programming, variables are usually represented by either single letters or alphanumeric strings[?].

Variables are useful in mathematics and computer programming because they allow instructions to be specified in a general way. If one were forced to use actual values, then the instructions would only apply in a more narrow, and specific, set of situations. For instance, by using variables, we can Now, all we need to do to find the square of a number is replace x with any number we want. For example: specify a mathematical definition for finding the square of ANY number: square(x) = x * x.

  • square(x) = x * x = y
  • square(1) = 1 * 1 = 1
  • square(2) = 2 * 2 = 4
  • square(3) = 3 * 3 = 9
etc...

In the above example, the variable x is a "placeholder[?]" for ANY number. One important thing we are assuming is that the value of each occurrence of x is the same -- that x doesn't get a new value between the first x and the second x. In computer programming, such changes can occur.


Put this code on your site

This article is licensed under the GNU Free Documentation License.
You may copy and modify it as long as the entire work (including additions) remains under this license.
To view or edit this article at Wikipedia, follow this link.