My issue
what is error in my code
My code
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main() {
int n;
cin>>n;
string str=" ";
while(n>0)
{
if(n%2==0)str+='0';
else
str+='1';
n=n/2;
}
for(int i=str.length();i>0;i--)
{ cout<<str[i];
}
cout<<endl;
}
Learning course: Bit manipulation
Problem Link: Decimal to binary Practice Problem in Bit manipulation - CodeChef