Find Out the Binary Number to Decimal Number in C Programming

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,a,sum=0,i=0;
clrscr();
printf("enter binary number");
scanf("%d",&n);
while(n>0)
{
a=n%10;
sum=sum*a*pow(2,i);
n=n/10;
i++;
}
  printf("dc=%d",sum);
  getch();
}

Post a Comment

0 Comments