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

Constants- needs & definition

“Constant are those that do not change while executing the program.”

BASIC deals with two types of constant:

  1. Numeric constant
  2. String constant

Numeric Constant

All numbers belong to this category because their values remain constant. They make take any of the following forms:

+95       (positive integer)

95        (positive integer)

62.5      (positive real)

-135     (negative integer)

-0.7     (negative real)

1.32E+5  (1.32*105 )

-5E-2      (-5 * 10-2)

The notation E stands for “times 10 to the power”. This would appear in computer output whenever the magnitude of a number to be output is quite large, or a number is very close to zero. The exponent can be either positive or negative but cannot be real number. Further, the length of the exponent is limited to two digits.

While writing constant, it is worth remembering the following points:

  1. A number can normally have up to a maximum of eight digits. However, the varies with the system and therefore the system manual should be consulted for correct size.
  2. Commas are not allowed in a numeric constant.
  3. The use of + sign is optional but – sign should be used if the number is negative.
  4. The length of exponent should not be more than two digits and it can contain – or + sign. Again + sign is optional.
  5. BASIC does not make any distinction between integer and fractional numbers.

 

String Constant

A String constant is any set of valid BASIC characters enclosed in quotation marks. The Quotation marks do not form part of the string.

Strings are used to represent non-numeric information such as names of persons and places, addresses, days, months and years, etc.

Some examples are:

“India”

“World”

“Hello”

“Aug 15, 2012”

“123”

“12 + 27”

“& &”

Download Paper Solutions from Below Link

About admin

Scroll To Top