Variable Declaration - Research Article from World of Computer Science

This encyclopedia article consists of approximately 1 page of information about Variable Declaration.
Encyclopedia Article

Variable Declaration - Research Article from World of Computer Science

This encyclopedia article consists of approximately 1 page of information about Variable Declaration.
This section contains 232 words
(approx. 1 page at 300 words per page)

Variable declaration refers to the need to declare a variable before the variable can be used in a program. The declaration of variables is made via a variable declaration statement.

Variable declaration is a means of notifying the compiler—a program that translates source code into object code--about the existence and nature of a variable. Items of concern would include the type of variable, the variable name and information about the memory that has been allocated for the variable. A variable declaration tells the compiler to allocate enough memory to hold a value of this data type, and to associate the identified memory with the location.

The subsequent allocation of storage for the variable by the compiler represents another process often termed as variable definition. Although declaration and definition often occur almost simultaneously and cannot be distinguished, they are different functions. A variable declaration begins with "var." Then it declares a variable identifier whose type can be specified by a type identifier or a type definition. Various types of definitions are possible, including an array, a record, a set and a subrange. One example of a variable declaration would read as:

  • var
  • variable identifier: type identifier;
  • ...
  • variable identifier: type identifier

or a similar statement, except that the command phrase "type definition" is substituted for "type identifier."

Following its declaration, a variable is available for use in a program.

This section contains 232 words
(approx. 1 page at 300 words per page)
Copyrights
Gale
Variable Declaration from Gale. ©2005-2006 Thomson Gale, a part of the Thomson Corporation. All rights reserved.