Skip to content

Instantly share code, notes, and snippets.

@doylemark
Created November 14, 2021 21:59
Show Gist options
  • Save doylemark/33f1682d9e069c14f3e7da077b7d0504 to your computer and use it in GitHub Desktop.
Save doylemark/33f1682d9e069c14f3e7da077b7d0504 to your computer and use it in GitHub Desktop.
Print an integer in base two representation
#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