C examples for Language Basics:printf
You can display integers in octal or hexadecimal format using %o and %x, respectively.
For uppercase hexadecimal format, use the %X format specifier; for lowercase, use %x, as shown here:
#include <stdio.h> int main(void) { unsigned num;//from w ww .j a v a2 s .c om for (num = 0; num < 16; num++) { printf("%o ", num); printf("%x ", num); printf("%X\n", num); } return 0; }