Types Of C Constants
C Constants can be divided into two major Categories.
- Primary Constants
- Secondary Constants
Primary Constants : Integer Constant , Real Constant , Character Constant.
Secondary Constants: Array, Pointer,Structure,Union,Enum,etc..
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 is assumed to be positive.
- no commas or or blanks are allowed with in an integer constant.
- the allowable range for integer constants is -32768 to 32767.
Rules For Constructing Real Constants
Real Constants are often called Floating point constants.The real Constants Could be Written in two forms
- Fractional form
- Exponential form
Rules :
Constants Expressed in fractional form
- A real Constant Must have at least one digit.
- it must have a decimal point.
- it could be either positive or negative.
- default sign is positive.
- no commas or blanks are allowed within a real constant.
Constants Expressed in Exponential form
- The mantissa part and the exponential part should be Separated by a letter '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 exponential form is -3.4e38 to 3.4e38.
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.Both the inverted commas should point to the left.
- For Example, 'A' is a valid character constant whereas 'A' is not.
- The Maximum length of a character constant can be 1 character.
No comments:
Post a Comment