Integer Constant in C++
Q3. How many ways are there in C++ to represent an integer constant?
Ans. In C++, an integer constant can be represented in 3 ways:
- As a decimal integer constant in which the integer constant consists of a sequence of digit but it does not begin with digit 0 (zero). For example, 1234 is a decimal integer constant but 01234 is not a decimal integer constant.
- As an octal integer constant in which the integer constant begins with digit 0 (zero). For example, 9 (in decimal) can be written as 011 (octal equivalent of 9) as octal integer.
- As a hexadecimal integer constant in which the integer begins with ox or OX. For instance, 11 (in decimal) can be written as OXB (hexadecimal equivalent of 11).