Types Of Integer Constants.

Q10. How many types of integer constants are allowed in C++? How are they written?

Ans. C++ allows three types of integer constants:

  1. Decimal (base 10),
  2. Octal (base 8),
  3. Hexadecimal (base 16).

 

  1. Decimal Integer Constants:

An integer constant consisting of a sequence of digits is taken to be decimal integer constant unless it begins with 0 (digit zero).

For instance, 1234, 41, +97, -17 are decimal integer constants.

  1. Octal Integer Constants:

A sequence of digits starting with 0 (digit zero) is taken to be an octal integer.

For instance, decimal integer 8 will be written as 010 as octal integer. (… 810 = 108) and decimal integer 12 will be written as 014 as octal integer (… 1210 = 148).

  1. Hexadecimal Integer Constants:

A sequence of digits preceded by 0x or 0X is taken to be an hexadecimal integer.

For instance, decimal 12 will be written as 0XC as hexadecimal integer.

Leave a Reply

Your email address will not be published. Required fields are marked *

11 Views
%d bloggers like this: