program to convert binary to decimal using c
#include<stdio.h>
int main()
{
int n,rem,d,j=1,dec=0;
printf("Enter the number in binary");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
d=rem*j;
dec=dec+d;
j*=2;
n=n/10;
}
printf("decimal is=%d",dec);
}
int main()
{
int n,rem,d,j=1,dec=0;
printf("Enter the number in binary");
scanf("%d",&n);
while(n>0)
{
rem=n%10;
d=rem*j;
dec=dec+d;
j*=2;
n=n/10;
}
printf("decimal is=%d",dec);
}
Comments
Post a Comment