Hexadecimal to Decimal in CWhat is Hexadecimal?The hexadecimal is also known as base16, it is a number system that uses the 16 symbols to represent a particular value, and these symbols are from (09 and AF). What is Decimal?The decimal is the number system that represents both the integer and noninteger numbers. This number system is also known as the base10 system, and it uses 10 symbols from (09) to represent a particular value. Conversion of Hexadecimal to Binary number We know that hexadecimal number contains 16 symbols, i.e., 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F where A,B,C,D,E,F represents (10,11,12,13,14,15) values. We can find the decimal number by extracting the digits from a hexadecimal number, and starting from the rightmost digit of the number. Each digit of the hexadecimal number is multiplied with the base 16. We will store the result of this multiplication in a particular variable. Let?s understand through an example. If the hexadecimal number is 5A, then its decimal value would be: decimal_value = 5*16^{1} + 10*16^{0} Now, we understand the conversion of hexadecimal number into a decimal number diagrammatically: In the above diagram, we consider 2AB as a hexadecimal number and calculated its decimal value. 2AB (Hexadecimal value) = 2*16^{2 }+ 10*16^{1,} + 11*16^{0} Let?s understand through the program. In the above program, we find the decimal number of a given hexadecimal number. In the above case, we take input from the user and store its value in the hex variable. After retrieving the input from the user, we calculate the length of the input and store it in the len variable. We have iterated each digit of a hexadecimal number and stores the final result in the decimal_value variable Output
Next TopicOctal to Hexadecimal in C
