📅  最后修改于: 2022-03-11 14:57:23.380000             🧑  作者: Mango
#include
#include
void main()
{
long int binary,hexadecimal=0,j=1,rem;
printf("Enter a binary number:\n");
scanf("%ld",&binary);
while(binary!=0)
{
rem=binary%10;
hexadecimal=hexadecimal+rem*j;
j=j*2;
binary=binary/10;
}