Binary to decimal

Another Solution for Binary to Decimal:


SOURCE CODE:


#include stdio(.)h
#include conio(.)h

void showbits(int h)
{
if(h==1)
printf("%d",h);
else
{
showbits(h/2);
printf("%d",h%2);
}
}
main()
{
int num;
void showbits(int h);

printf("BINARY : ");
scanf("%d",&num);
printf("\nBinary of %d equivalent to decimal is ",num);
showbits(num);
getch();
}

0 comments:

Post a Comment