You can access this code on my Github profile.
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Enter a Number: ";
cin>>n;
int rem=n%2;
while(true){
if(rem==0){
n=n/2;
int rem=n%2;
cout<<rem;
}
else{
int rem=n%2;
n=n/2;
cout<<rem;
}
if(n==0){
break;
}
}
}```
Top comments (1)
This is inefficient due to division and modulus. You really should cast to
uint64_t
and use<<
and&
.