Variable
In computer science and mathematics, a variable is a symbol denoting a quantity or symbolic representation. In mathematics, a variable often represents an unknown quantity; in computer science, it represents a place where a quantity can be stored. Variables are often contrasted with constants, which are known and unchanging.
Why are variables useful?
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 example:
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
specify a mathematical definition for finding the square of ANY number: square(x) = x · x.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Now, all we need to do to find the square of a number is replace x with any number we want.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
- 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 does not get a new value between the first x and the second x.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
In computer programming languages without referential transparency, such changes can occur.
Related Topics:
Computer - Programming language - Referential transparency
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ Table of Content ~
| ► | Introduction |
| ► | General overview |
| ► | Why are variables useful? |
| ► | Computer programming |
~ What's Hot ~
~ Community ~
| ► | History Forum Come and discuss about History, Civilizations, Historical Events and Figures |
| ► | History Web-Ring A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site. |
and are licensed under the GNU Free Documentation License.
Lexicon - Privacy Policy - Spiritus-Temporis.com ©2005.
