program in c to binary number to a decimal number


program in c to binary number to a decimal number
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
long int n,res=0,i=0;
clrscr();
printf(“ enter the binary digit “);
scanf(“%d”,&n);
for(;n>0;)
{
r=n%10;
res+=r*pow(2,i);
i++;
n=n/10;
}
printf(“decimal equivalent is %d”, res);
return 0;
}

output:
enter binary digit:111
decimal equivalent is:7

Comments

Popular posts from this blog

C Program to implement GAUSS' FORWARD INTERPOLATION FORMULA

c Program to implement GAUSS' BACKWARD INTERPOLATION FORMULA

Program to implement BESSELS INTERPOLATION FORMULA in C