Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,i=0,num,t;
- cout<<"Enter a number : ";
- cin>>n;
- while (n!=0)
- {
- if (n%2==1)
- {
- t=1;
- for(int j=0;j<i;j++)
- {t=t*10;}
- num=num+t;
- }
- n=n/2;
- i++;
- }
- cout<<num;
- }
Advertisement
Add Comment
Please, Sign In to add comment