This algorithm prints the bits from low to high order:
#include using namespace std;int main() { int n; // number to convert to binary while (cin >> n) { if (n > 0) { cout << n << " (decimal) = "; while (n > 0) { cout << n%2; n = n/2; } cout << " (binary) in reverse order" << endl; } else { cout << "Please enter a number greater than zero." << endl; } }//end input loop on n return 0;}