TheAlgorithms-C/conversions/binary_to_hexadecimal.c
Nicola Masarone 8282804d68
Update binary_to_hexadecimal.c
Last printf() upper/lower case fix: from "THe" to "The" and from "Equivalent" to "equivalent"
2020-10-29 22:25:36 +01:00

22 lines
455 B
C

/*
* C Program to Convert Binary to Hexadecimal
*/
#include <stdio.h>
int main()
{
long int binary, hexa = 0, i = 1, remainder;
printf("Enter the binary number: ");
scanf("%ld", &binary);
while (binary != 0)
{
remainder = binary % 10;
hexa = hexa + remainder * i;
i = i * 2;
binary = binary / 10;
}
printf("The equivalent hexadecimal value: %lX", hexa);
return 0;
}