Represent octal and hex number in c :
In daily life we write numbers in base 10. Binary number has base 2. Similarly octal and hex numbers has base 8 and 16 respectively.
C provides a feature to assign variables in octal and hex representation.
To assign octal value to int variable precede value with 0 (zero) .
You can represent octal values as 016
int x=016; // It’s decimal value is 14
To assign hex value to int variable precede value with 0x or oX .
int x=0x18; // It’s decimal value is 24
C code to represent value in octal and hex then print them in decimal
To print the values in octal and hex we have format specifier %o and %x .
Too lean more about format specifier click here