// decimal to binary converter works for positive integers #include using namespace std; int main() { int N; cout << " Enter a decimal number " << endl; cin >> N; cout << " The number " << N << " in binary is: "; int value = 1; // figure out highest binary digit while (2*value <= N) { value = 2 * value; } while (value >= 1) { if (N >= value) { cout << "1"; N = N - value; } else { cout << "0"; } value = value / 2; } cout << endl << endl; // end with a newline and a blank line }