Breaking News
You are here: Home / Notes / SEM-1 / CPPM / Variables- needs & definition

Variables- needs & definition

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 variables

There are two types of Variables:

  1. Numeric variables
  2. String variables

Numeric variables create locations in computer memory for storing numeric constant while string variables do the same for string constants.

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:

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.

Download Paper Solutions from Below Link

About admin

Scroll To Top