Last active
December 25, 2017 16:20
-
-
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.
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<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