Constants
Constants:-
A.
Integer
Constants :-
An integer constant refers to sequence
digits. There are three types of integers, namely decimal, octal, and
hexadecimal integer. Decimal integer consists of set of digits, 0 to 9.it is
preceded by an optional – or + sign. E.g. 123, -345, 0, 685478, +14. Embedded
spaces, commas, and non digit characters are not permitted between digits e.g.
15 570, $40, etc. An octal integer constant consists of any combination of
digits from 0 to 7 with leading 0 e.g. 0373, 0, 0435, etc. A sequence of digits preceded by 0x or 0X is
considered as hexadecimal integer. They may also include alphabets A to F or a
to f. The letter A to F represent number 10 to 16. E.g. 0X2, 0x9f, 0Xbcd, 0x,
etc.
B.
Real
Constants:-
Quantities are represented by
containing fractional part like 17.25; such numbers are called as real
constants. These numbers are shown in decimal notation, having a whole number
followed by a decimal point and fractional part. Real no may also expressed in
exponential notation. e.g. 215.65 may be written as 2.1565e2 exponential
notation. e2 means multiply by 102 Some examples of real constant
are 0.00083, .95, -0.217, 12e2, 3.18E2, etc.
Character
Constants:-
A.
Single
character constants:-
A single character constant or
character constant contains a single character enclosed within a pair of single
quote mark i.e. ( ‘ ’ ). E.g. ‘X’, ‘5’, ‘;’, ‘ ’, ‘x’, etc. Character constant ‘5’ is not
the same as integer number 5.
B.
String
Constants:-

Comments
Post a Comment