C program for converting hex number to decimal and character

converting hex number to binary in c
c program for hex to char
c program for converting hex to decimal

Click here to see ASCII table for hex to char

Click here to know hex to decimal converter

Logic :-

Step 1
Hex number is 21
separate high bit 2 and low bit 1

Step 2
convert 2 into binary 0010 and 1 into binary 0001
now 21 in binary is 00100001

Step 3
convert 00100001 to decimal by multiplying by power of 2
0x(2^7)+0x(2^6)+1x(2^5)+0x(2^4)+0x(2^3)+0x(2^2)+0x(2^1)+1x(2^0)
0+0+ 32+0+0+0+0+1
33


Program:-

Main function






binarylow function

binaryhigh function


Output:-

Enter Hex Number
21
hex 21 is in decimal is 33
hex 21 is in char is !

Enter Hex Number
4c
hex 21 is in decimal is 76
hex 4c is in char is L

Enter Hex Number
hex 21 is in decimal is 43
2b
hex 2b is in char is +

Click here to download this program

Leave reply

Add your comments here

Back to Top