Skip to content

Instantly share code, notes, and snippets.

@jagdish4501
Created May 10, 2021 10:56
Show Gist options
  • Save jagdish4501/66d50164a40eb661cdac1983f21cf338 to your computer and use it in GitHub Desktop.
Save jagdish4501/66d50164a40eb661cdac1983f21cf338 to your computer and use it in GitHub Desktop.
Let us c Q.A positive integer is entered through the keyboard, write a function to find the binary equivalent of this number using recursion.
#include <stdio.h>
int fun(int num);
int main()
{
int num;
printf("Enter Number: ");
scanf("%d", &num);
printf("Decimal To Binary: %d", fun(num));
}
int fun(int num)
{
if (num == 0)
{
return 0;
}
else
{
return ((num % 2) + 10 * fun(num / 2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment