Created
November 14, 2021 21:59
-
-
Save doylemark/33f1682d9e069c14f3e7da077b7d0504 to your computer and use it in GitHub Desktop.
Print an integer in base two representation
This file contains hidden or 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 findBinary(int n) | |
{ | |
if (n == 0) | |
{ | |
return 0; | |
} | |
return (n % 2 + 10 * findBinary(n / 2)); | |
} | |
int main() | |
{ | |
int n; | |
scanf("%d.", &n); | |
printf("%d", n); | |
printf("%d.\n", findBinary(n)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment