Answers for "recursion to convert decimal to binary"

C
0

recursion to convert decimal to binary

#include <stdio.h>
 
int decimal_binary(int n)
{
    if (n==0)
        return 0;
    else
        return ((n%2)+10*decimal_binary(n/2));
}
 
void main()
{
   int no;
 
   printf("Enter a decimal number\n");
   scanf("%d",&no);
   printf("Decimal(%d) = Binary(%d)\n",no,decimal_binary(no));
}
Posted by: Guest on March-03-2022
0

recursion to convert decimal to binary

#include <stdio.h>
 
int decimal_binary(int n)
{
    if (n==0)
        return 0;
    else
        return ((n%2)+10*decimal_binary(n/2));
}
 
void main()
{
   int no;
 
   printf("Enter a decimal number\n");
   scanf("%d",&no);
   printf("Decimal(%d) = Binary(%d)\n",no,decimal_binary(no));
}
Posted by: Guest on March-03-2022

Code answers related to "recursion to convert decimal to binary"

Code answers related to "C"

Browse Popular Code Answers by Language