variable
In programming, a structure that holds data and is uniquely named by the programmer. It holds the data assigned to it until a new value is assigned or the program is finished.
Control Values
Variables are widely used to hold control values that keep track of something. For example, the C statement FOR (X=0; X<5; X++) performs the instructions following the statement within open and closed curly braces ({ and }) five times, and X is keeping track of that number of iterations. X is a variable set to zero (x=0), incremented by 1 (x++) and compared to 5 (x<5). The reason it is less than 5 (<5) is because we started with 0.
The Equals Sign
Variables are usually assigned with an equal sign. Numbers are unquoted; for example: COUNTER = 1 places the digit 1 in the variable COUNTER. Character data (text) requires quotes; for example: PRODUCT = "abc1234". In some languages, the type of data must be declared before it is assigned; for example, in C/C++, the statement INT COUNTER creates a variable that holds only whole numbers (integers).
Local and Global
A local variable is one that is referenced only within the subprogram, function or procedure it was defined in. A global variable can be used by the entire program. See undefined variable and local variable.
Computer Desktop Encyclopedia THIS DEFINITION IS FOR PERSONAL USE ONLY
All other reproduction is strictly prohibited without permission from the publisher.
Copyright © 1981-2009 by Computer Language Company Inc. All rights reserved.
Browse dictionary definitions near variable
Share on Facebook