Variable

From LQWiki
Jump to navigation Jump to search

In programming a variable is a part of memory, usually having a name. It stores a value (it may be integer, floating point, string etc.) that can be read or written using the variable's name.

Example (in C language):

int a=3;
a=5;
if( a > 4 ) printf("A is more than 4!\n");

In the first line the variable a is set to 3. Then it's changed to 5. In the last line, the variable's value is read and if it's more than 4, a message is printed.

See also