All pastes #900660 Raw Edit

Untitled

public text v1 · immutable
·published 2008-02-12 02:00 UTC
rendered paste body
#include <iostream>
using namespace std;
void binario(int);

int main(void) {
        int numero;

        cout << "Ingrese un numero entero positivo ";
        cin >> numero;
        if (numero < 0) 
                cout <<"Eso no es un numero entero positivo.\n";
        else {
                cout << numero << " Convertido a binario es: ";
                binario(numero);
                cout << endl;
        }
        return 0;
}

void binario(int numero) {
        int resto;

        if(numero <= 1) {
                cout << numero;
                return;
        }

        resto = numero%2;
        binario(numero >> 1);    
        cout << resto
        ;
}