This C Program Converts the given Binary to Hexadecimal . Binary number is a number that can be represented using only two numeric symbols – 0 and 1. A number in base 2. Hexadecimal is base 16 arithmetic where each digit is a value from 0 to 15, rather than the 0-9 of base 10.
Here is source code of the C program to Convert Binary to Hexadecimal . The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C Program to Convert Binary to Hexadecimal
long int binaryval, hexadecimalval = 0, i = 1, remainder;
printf("Enter the binary number: ");
while (binaryval != 0)
remainder = binaryval % 10;
hexadecimalval = hexadecimalval + remainder * i;
i = i * 2;
binaryval = binaryval / 10;
printf("Equivalent hexadecimal value: %lX", hexadecimalval);
Output: $ cc pgm7.c $ a.out Enter the binary number: 10000 Equivalent hexadecimal value: 10
Sanfoundry Global Education & Learning Series – 1000 C Programs.