Showing posts with label Decimal to binary using recursion. Show all posts
Showing posts with label Decimal to binary using recursion. Show all posts

Monday, September 12, 2011

Decimal to binary using recursion

#include<stdio.h>
#include<conio.h>

main()
{
int n;
clrscr();
printf("\nEnter any decimal no.:");
scanf("%i",&n);
printf("\nBinary equivalent of %d =");
convert(n);
getch();
}

int convert(int x)
{
int i;
    if (x==0)
       return(0);

    i=x%2;
    convert(x/2);
    printf(" %d",i);
}

read about Decimal to Binary

Popular 5 Posts Last 7 days