decimal to binary converter c++? -
int inputnumber=0; int divisionstore=0,modstore=0; vector<int> mainvector; cout << "\nenter number convert binary.\n" << endl; cin >> inputnumber; { modstore=inputnumber%2; inputnumber=inputnumber/2; mainvector.push_back(modstore); }while(inputnumber!=1); (int i=0;i<mainvector.size();i++) { cout<<endl<<mainvector[i]<<endl; }
seems there logical error cant find whats wrong it? program not print correct conversion seems loop ends before can push last number.
i think need change:
}while(inputnumber!=1)
to:
}while(inputnumber!=0)
Comments
Post a Comment