Header Ads

Learn Together, Stay Connected.

Converting DECIMAL to BINARY



 #include<bits/stdc++.h>

using namespace std;

#define file() freopen("in.txt","r",stdin)

#define IO ios_base::sync_with_stdio(false),cin.tie(0)



int main()
{
int n;
cin>>n;
for(int c=31;c>=0;c--)
{
int k=n>>c;
if(k&1) {
cout<<1;
}
else cout<<0;
}
cout<<endl;

return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.