online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Esercizio 8. Leggere tre caratteri che rappresentano le cifre di un numero esadecimale e calcolarne il valore in decimale e poi stamparlo. *******************************************************************************/ #include <iostream> using namespace std; int main() { char c1,c2,c3; cout<<"inserisci tre cifre di un numero esadecimale "<<endl; cin>>c3; cin>>c2; cin>>c1; int valore=0; if(c1>='0'&&c1<='9') { valore=c1-'0'; } if(c1>='a'&&c1<='f') { valore=c1-'a'+10; } if(c2>='0'&&c2<='9') { valore=valore+(c2-'0')*16; } if(c2>='a'&&c2<='f') { valore=valore+(c2-'a'+10)*16; } if(c3>='0'&&c3<='9') { valore=valore+(c3-'0')*16*16; } if(c3>='a'&&c3<='f') { valore=valore+(c3-'a'+10)*16*16; } cout<<"il numero esadecimale "<<c3<<c2<<c1; cout<<" in decimale vale "<<valore; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue