Write a program to find the binar equivalent of this number using recursion. A positive integer is entered through the keyboard. Like Decimal Value 2(Input)-Binary value 10(Output).
I know how to convert decimal to binary but I’ve found that converting binary to decimal is much much harder. Maybe my knowledge about the codes is limited to most most basic.

//Binary equivalent of a binary number

#include
#include
int binary (int);
void main()
{
int num;
clrscr();
printf(“nEnter The Number: “);
scanf(“%d”,#);
binary(num);
printf(“nnnnnPress any key to exit…..”);
getch();
}
//function to convert deciaml to binary
int binary (int n)
{
int r;
r=n%2;
n=n/2;
if (n==0)
{
printf(“nThe binary equivalent is %d”,r);
return(r);
}
else
binary(n);
printf(“%d”,r);
}

1 COMMENT

  1. I’m really enjoying the design and layout of your website. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme? Outstanding work!