An integer constant refers to a sequence of digits without decimal point.
Rule for constructing integer constants are :
- An integer constant must have at least one digit .
- An integer constant contains neither a decimal point nor an exponent.
- Commas and blank Spaces cannot be included within the number.
- Sign ( + or – ) must precede the number .
- Default sign is positive .
- The allowable range for integer constants for a 16 bit computer is – 32768 to + 32767
There are three type of integer constants , namely , decimal , octal and hexadecimal.
( a ) Decimal integers consists of a set of digits 0 through 9 .
Example : The following are valid decimal integer constants
18 – 11 +39 0 8752
On the other hand , the following are not valid integer constants
28.0 contains a decimal point
12,250 contains a comma
5- Sign does not precede
40 20 Blank spaces are not allowed
( b ) An octalinteger constant consists of any combination of digits from 0 through 7 , with a leading 0.
Example : The following are valid octal integer Constants
015 0375 0 0764 05
( c ) A hexadecimal integer constant consists of any combination of digits from 0 through 9 or alphabets a ( or A ) through f ( or F ) , with a leading 0x or 0X .
Example : The following are valid hexadecimal integer constants
0x5 0x7ab 0x6f 0xabc 0x975
We generally use decimal integer constant or simply integer constant in programming.