Skip to content

Instantly share code, notes, and snippets.

@masious
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masious/a6a628302f7793694199 to your computer and use it in GitHub Desktop.
Save masious/a6a628302f7793694199 to your computer and use it in GitHub Desktop.
DS Questions - Question 2 - C++
#include<iostream>
using namespace std;
long long binaryOf(int a){
return a?binaryOf(a/2)*10 + a%2:0;
}
int main(){
int a;
cin>>a;
cout<<binaryOf(a);
cout<<endl<<"Press any key to continue..."<<endl;
getchar();
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment