Hi, can you please tell me
How to use printf to find out the hex and octal values of 255?
Thanks a lot.
Hi, can you please tell me
How to use printf to find out the hex and octal values of 255?
Thanks a lot.
Try this:
printf("%x", 255); /* print hex representation of decimal 255 */
printf("%o", 255); /* print octal representation of decimal 255 */
Try using the o
and x
specifier of printf
printf("%d %o %x",255,255,255); // prints 255 377 ff
If you want to do this on shell you can do:
$ printf "%o\n" 255
377
$ printf "%x\n" 255
ff
$