I have a list of numbers as below:
0, 16, 32, 48 ...
I need to output those numbers in hexadecimal as:
00
Your code has no problem. It does print the way you want. Alternatively, you can do this:
printf("%04x",a);