diff --git a/exercises/binary_converter.cpp b/exercises/binary_converter.cpp index 19bf37d..c578640 100644 --- a/exercises/binary_converter.cpp +++ b/exercises/binary_converter.cpp @@ -5,3 +5,38 @@ Insert first number: 8 The binary number is: 1000 */ + +#include +#include + +using namespace std; + + +int main (){ + + int n; + + cout <<"Inserisci un Numero "; + + cin >>n; + + while (n > 0){ + + if (n%2 == 0 ){ + + cout<<0; + } + + else{ + + cout<<1; + } + // si legge al contrario + n = n/2; + } + + +} + + +