How to print hexadecimal in c
Using %x format specifier in printf, we can print the hexadecimal values.
%x
%x will print the hexadecimal in small letters.
Like, aaff2, ffd etc.
Example
#include<stdio.h> int main() { int i = 255; printf("255 in hexadecimal = %x\n",i); return 0; }
Output
255 in hexadecimal = ff
%X
%X will print the hexadecimal in capital letters.
Like, AAFF2, FFD etc.
Example
#include<stdio.h> int main() { int i = 255; printf("255 in hexadecimal = %X\n",i); return 0; }
Output
255 in hexadecimal = FF
Useful Resources
https://www.log2base2.com/number-system/hexadecimal-number-system.htmlhttps://www.log2base2.com/number-system/hex-to-decimal.html