program to print binary equivalent of a decimal number Note MSP should print first and LSB last.



main()
{
int n;
printf("\nEnter any number:"); scanf("%d", &n); dec2bin(n);
} dec2bin(int n)
{
if(n == 0)
return ; else
{
dec2bin (n/2); printf("%d", n%10);
}
}

1 comment:

  1. How I can print the remaider of dviding by 2 each time in a reverse order

    ReplyDelete