C++ Integer Types decimal, octal, and hexadecimal

Introduction

Integer literals can be decimal, octal, and hexadecimal.

Octal literals start with a prefix of 0, and hexadecimal literals begin with a prefix of 0x.

int main() 
{ 
    int x = 10;     // decimal literal 
    int y = 012;    // octal literal 
    int z = 0xA;    // hexadecimal literal 
} 

All these variables have been initialized to a value of 10 represented by different integer literals.

For the most part, we will be using decimal literals.




PreviousNext

Related