0

Im doing my project on number conversion. I found the coding below. can anyone help me to explain the coding. why the coding have "count"? why the "count + 1"? what function of "count"?

```
void Bin2Dec()
{
long int a[20],i,n,count=0,b[20],c[20],sum=0;
printf("\n Enter a binary number to convert to decimal form:");
scanf("%ld",&n);
for (i=0;n>=1;i++)
{
a[i]=n%10;
n=n/10;
count=count + 1;
}
for (i=0;i<=count-1;i++)
{
b[i]=pow(2,i);
}
for (i=0;i<=count-1;i++)
{
c[i]=a[i] * b[i];
sum = sum + c[i];
}
printf(" The decimal form for the binary number is %ld\n",sum);
}
```

All the replies will save my marks..thank you~

*Edited 5 Years Ago by Narue*: added code tags