Convert any Number To Binary
Here is the code to convert decimal number to a binary number
void solve() {
int n;
cin>>n;
int ans=0;
int power=1;
while(n){
int curr=(n&1);
ans+=power*curr;
power*=10;
n=n/2;
}
cout<<ans<<endl;
}
Thank you for reading this.
0 Comments
If you have any doubts/suggestion/any query or want to improve this article, you can comment down below and let me know. Will reply to you soon.