Skip to content

Conversation

@Naveen449
Copy link

#include <bits/stdc++.h>
using namespace std;

string decimal_to_binary(int n)
{
string ans;
while(n>0){
int current_bit = n&1;
ans+=current_bit+'0';
n>>=1;
}
reverse(ans.begin(),ans.end());
return ans;
}
int main()
{
string binary = decimal_to_binary(244);
cout << binary << endl;
return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant