Printing value in Decimal, Octal, Hexadecimal using printf in C
This code snippet will print an entered value in Decimal, Octal and Hexadecimal format using printf() function in C programming language. By using different format specifier we can print the value in specified format.
Print value in Decimal, Octal ad Hex using printf() in C
Output
Decimal value is: 2567 Octal value is: 5007 Hexadecimal value is (Alphabet in small letters): a07 Hexadecimal value is (Alphabet in capital letters): A07Here, following format specifiers are used:
- %d - to print value in integer format
- %o - to print value in octal format
- %x - to print value in hexadecimal format (letters will print in lowercase)
- %X - to print value in hexadecimal format (letters will print in uppercase)
need an explanation for this answer? contact us directly to get an explanation for this answer