1. Character constant
A character constant is a character string
enclosed in apostrophes (sometimes called "single
quotes" when used this way).
2. Real constant
A string of digits and one period, used as a decimal
point, is called a real constant. The following
are real constants:
13.6 .1234567 3.0
00.30
Real constants are also written with an exponent
(E). The letter "E" is read as "times
ten to the power" and the integer following the
"E" is a power of ten to be multiplied by
the real number. This form, called the exponential
notation, is useful for writing very large or very
small numbers. For instance, 2.3E5 is 2.3 times ten
to the power 5 or 2.3 X 100000 = 230000. The integer
power may have a minus sign preceding it as in the
real constant 2.3E-5, which is 2.3 times 10 to the
power -5 or 2.3 X .00001 = .000023.
3. Integer constant
An integer constant is a string consisting only of
the digits 0 to 9, such as the following:
24 0 1234567
Q. 13. Write which of the following FORTRAN constants
are invalid:
(i) -3/4 (June 2002, June 2001)
(ii) 0.01540E05 (Dec. 2001)
(iii) -0.148E - 5 (Dec. 2001)
(iv) 125.8E (Dec. 2001)
(v) 12.5E + 4 (June 2001)
(vi) 12345 (June 2001)
(vii) 25 (June 2001)
(viii) 30, 416 (Jan. 2001)
(ix) 1.2E14 (Jan. 2001)
(x) -1/2 (Jan. 2001)
(xi) 4E1.4 (June 2000,
Dec. 99)
(xii) 97.52 (June 2000)
(xiii) 2, 489.70 (June
2000, Dec. 99)
(xiv) 1.6E128 (Dec. 99)
Ans. (i) Invalid constant because no fractions
are allowed.
Ans. (ii) Valid real constant.
Ans. (iii) Valid real constant.
Ans. (iv) Invalid constant.
Ans. (v) Valid real constant.
Ans. (vi) Valid integer constant.
Ans. (vii) Valid integer constant.
Ans. (viii) Invalid constant as comma (,) is
not allowed in any constant.
Ans. (ix) Valid constant.
Ans. (x) Invalid constant because no fractions
are allowed.
Ans. (xi) Invalid constant because exponent
cannot be a real number.
Ans. (xii) Valid integer constant.
Ans. (xiii) Invalid constant because comma
(,) is not allowed.
Ans. (xiv) Invalid constant because exponent
is too large.
|