Friday, March 26, 2010

Binary to Decimal

int main()
{
int a[8],i,j=1,b=0;
clrscr();
for(i=0;i<8;i++)
scanf("%d",&a[i]);
for(i=7;i>=0;i--)
{
b+=(a[i]*j);
j=j*2;

}
printf("%d",b);
getch();
return 0;
}

0 comments:

Post a Comment