I am trying to print hexadecimal values in c.
A simple known program to print hexadecimal value…( Using %x or %X format specifer)
#include<stdio.h>
int main()
{
unsigned int num = 10;
printf("hexadecimal value of %d is %x\n",num,num);
Output :
hexadecimal value of 10 is a
Instead of getting input as ‘a’
I need to get output as 0xa ~ in hexadecimal format ( making the user to understand the value as hexadecimal more better)
>Solution :
Use %#x instead of %x the in the printf() format string.