Created
May 10, 2021 10:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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