You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
programming-examples/c/Basic/C program for Binary to dec...

16 lines
378 B
C

/*binary to decimal conversion:*/
#include<stdio.h>
void main()
{
long int bn,dn=0,j=1,remainder;
printf("Enter any number any binary number: ");
scanf("%ld",&bn);
while(bn!=0)
{
remainder=bn%10;
dn=dn+remainder*j;
j=j*2;
bn=bn/10;
}
printf("Equivalent decimal value: %ld",dn);
}