<<< Integer Types     Index     Floating-Point Numbers >>>

14. Integer Literals

  • Integer literals are numeric constants, or numerals, in our programs.

  • There are 3 literal notations in C++,

    • decimal: 2

    • octal: 02

    • hexadecimal: 0x2

  • See also: Hexadecimal Notation

  •  

    
    #include <iostream> 
    int main() 
    { 
        int x = 15;   // decimal-15
        int y = 015;  // octal-15 (decimal 13)
        int z = 0x15; // hexadecimal-15 (decimal 21)
        return 0;
    } 
    
    

<<< Integer Types     Index     Floating-Point Numbers >>>