C constants can be divided into two major categories
(a) Primary Constants
(b) Secondary Constants
This constants are further categorised as shown in figure 1
(a) Primary Constants
(b) Secondary Constants
This constants are further categorised as shown in figure 1
![]() |
| Figure 1 |
Rules for Constructing Integer Constants
- An integer constant must have at least one digit.
- It must not have a decimal point.
- It can be either positive or negative.
- If no sign precedes an integer constant, it is assumed to be positive.
- No commas or blanks are allowed within an integer constants.
- The allowable range for integer constants is -214783648 to 214783647 ( for C/C++ it is -32768 to 32767).
+4234
-956
-8000
Rules for Constructing Real Constants
Real Constants are also called Floating Point Constants. The Real constants could be wriiten in two forms - Fractional Form and Exponential Form.
Following rules must be observed while constructing real constants expressed in fractional form:
- A real constants must have at least one digit.
- It must have a decimal points.
- It could be either positive or negative.
- Default sign is positive.
- No commas or blanks are allowed within a real constant.
4260.0
-32.789
-4875.96
The exponential form of represantation of real constants is usually used if the value of the constants is either very small or too large.
In exponential form of represantation, the real constants is represented in two parts. The part appearing before 'e' is called mantissa, whereas the part following 'e' is called exponent. Thus 0.000342 can be represented in exponential form as 3.42e-4.
Following rules must be observed while constructing real constants expressed in exponential form:
- The mantissa part and the exponential part shoud be separated by a letter E or e.
- The mantissa part may have a positive or negative sign.
- Default sign of mantissa part is positive.
- The exponent must have at least one digit, which must be a positive or negative integer. Default sign is positive.
- Range of real constants expressed in exponentia form is -3.4e38 to 3.4e38.
4.1e+8
-0.2e9
3.2E26
Rules for Constructing Character Constants
- A character constant is a single alphabet, a single digit, or a single special symbol enclosed within single inverted commas.
- The maximum length of a character constant can be 1 character.
'b'
'5'
'+'

Comments
Post a Comment