Skip to content

Instantly share code, notes, and snippets.

@imShakil
Last active December 25, 2017 16:20
Show Gist options
  • Save imShakil/8322c251bfe60cc5dab21e5fb94a3366 to your computer and use it in GitHub Desktop.
Save imShakil/8322c251bfe60cc5dab21e5fb94a3366 to your computer and use it in GitHub Desktop.
A Simple C++ code to convert Decimal number to Binary Number using recursive function.
#include<bits/stdc++.h>
using namespace std;
void BinaryPrint(int n)
{
if(n==0) return;
BinaryPrint(n/2);
printf("%d", n%2);
}
int main()
{
int n;
while(scanf("%d", &n)!=EOF) {
if(n==0)
printf("0");
else BinaryPrint(n);
printf("\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment