Teachers Paradise School Supplies Teacher Resources Free Encyclopedia
Teachers Paradise FREE Teaching Resources
Home Arts Crafts Audio Visual Equipment Office Supplies Teacher Resources
Main Page | Edit this page

Variable

A variable is something which is subject to change; the term is most commonly used in computer science and mathematics, where it denotes a quantity or symbolic representation (one which is often unknown).

Table of contents
1 General Overview
2 Why Are Variables Useful?
3 Computer Science

General Overview

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 stringss.

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.

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.

Computer Science

In C++, there are 2 types of variables: global and local variables. Global variables exist throughout a program; whereas, local variables only exist within a given statement block or function. The variables are defined via a declaration.



Pay for Educational Supplies & Teaching Supplies with Visa, Master Card, American Express, Discover or Paypal.
TeachersParadise.com HOME | Safe Shopping Guarantee | Help Desk
All trademarks & brands are the property of their respective owners.
Legal Notice 2000-2007 TeachersParadise.com, Inc. All Rights Reserved