2018-01-28 16:15:09 +03:00
|
|
|
/*
|
2020-05-29 23:23:24 +03:00
|
|
|
* C Program to Convert Binary to Hexadecimal
|
2018-01-28 16:15:09 +03:00
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
2020-05-29 23:23:24 +03:00
|
|
|
|
2018-01-28 16:15:09 +03:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
long int binary, hexa = 0, i = 1, remainder;
|
2020-05-29 23:23:24 +03:00
|
|
|
|
2018-01-28 16:15:09 +03:00
|
|
|
printf("Enter the binary number: ");
|
|
|
|
scanf("%ld", &binary);
|
|
|
|
while (binary != 0)
|
|
|
|
{
|
|
|
|
remainder = binary % 10;
|
|
|
|
hexa = hexa + remainder * i;
|
|
|
|
i = i * 2;
|
|
|
|
binary = binary / 10;
|
|
|
|
}
|
2020-10-30 00:25:36 +03:00
|
|
|
printf("The equivalent hexadecimal value: %lX", hexa);
|
2018-01-28 16:15:09 +03:00
|
|
|
return 0;
|
|
|
|
}
|