I was assigned to input a 4 digit by the user and output each number in every line. My question is in the code as comments that follows:
Code:#include <iostream> #include <string> using namespace std; void a(); void b(); void c(); void d(); bool die( const string & msg ); int main(){ a(); b(); c(); d(); } void a(){ unsigned noko1; cin >> noko1; if( !cin ) die( "non-numeric input" ); // if person inputs a non digit value complain and die if( noko1 <= 0 || noko1 > 9999 ) // this states the range beetween 1 and 1000 if not it dies die( "out of range"); if(noko1 == noko1) cout<<(noko1%10000)/1000<<endl; cout<<(noko1%1000)/100<<endl; cout<<(noko1%100)/10<<endl; cout<<(noko1%10)/1<<endl; // else what?? if i input else <<cout"do nothing" endl; // sends me an error // is it ok to leave it like this without the else? thanks } // a void b(){ } // b void c(){ } // c void d(){ } // d bool die( const string & msg ){ cerr <<endl <<"Fatal error: " <<msg <<endl; exit( EXIT_FAILURE ); } // die



LinkBack URL
About LinkBacks



