Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  fgs
Language: C/C++
Code:
#include<stdio.h>
#include<math.h>
int main ()
{int a, b,j,i,sum;
prinf("type the binary number");
sum = 0;
scanf("%d",&a);
for(i=1; ;i++)
{a=a/10;
    if(a<1) break;
}
for(j=i;j>0;--j)
{b=a/pow(10,j);
sum+=b*pow(2,j);
a=a-b*pow(10,j);}
printf("%d",sum);
}
          
          
          
          
          
          
Comments: