Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- using namespace std;
- int main() {
- unsigned int n;
- char num[200]="";
- cout << "Enter a positive decimal number: ";
- cin >> n;
- while(n>0) {
- if(n%2==0)
- strcpy(num,strcat(num,"0"));
- else
- strcpy(num,strcat(num,"1"));
- n=n/2;
- }
- int len=strlen(num);
- while(len>0) {
- cout << num[len-1];
- len--;
- }
- cout << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment