A variable is a data name that is used to store a data value which change during the program execution. The quantities which change during the program execution, these quantities are called variablesThere are two types of Variables:
- Numeric variables
- String variables
Numeric Variables Numeric variables can be any single letter of the alphabet or any single letter of the alphabet followed by one of the numerals 0, 1, 2, ….., 9.Thus, any of the following 286 entities could be used as numeric variables:
Note that a numeric variable should start with an alphabet and it should not contain any special character.
String Variables String constant should be handled by string variables. The method of naming and handling string constant differ a great deal from one system to the other. In most systems, the string variables are designated by a single alphabet followed by a dollar sign.
Thus, valid string variables are:
A$, B$, C$,……., Z$
In such a system there can be only 26 string variables.
Examples of naming string items are:
Items Possible names
NAME N$
COUNTRY C$
YEAR Y$
PROFESSION P$
SEX S$ And so on.
It should be remembered that any string variable can be used to store any string constant. There are certain systems that allow a string variable name to be any numeric variable name followed by a dollar sign.
Example of this type of variables are:
A$, A2$, X2$, Y$
In this case a total of 286 string variables could be used.
Post a Comment