View Single Post
Old 10-30-2006, 08:34 PM   #4 (permalink)
js2006
Recruit
 
Join Date: Oct 2006
Posts: 19
js2006 is on a distinguished road
something for it

done something with it ,

but i need improvement and like to see my prog working with above output i mean 12 bits on screen. how to do it ?

Like to see C++ code plz

Code:
#include <iostream>
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;
        }
    }
  return 0;
}//end main
js2006 is offline   Reply With Quote