12345678910111213141516171819202122232425262728293031323334353637383940414243444546
int main() { int lval =0; int rval = 0; char op; cin>>lval; if(!cin) //HOW DOE S THIS KNOW TO WAIT FOR AN OPERATOR cout<<"no first hand operator"; while(cin>>op) { cin>>rval; switch(op) { case '+': lval+=rval; break; case '-': lval-=rval; break; case '*': lval*=rval; break; case '/': lval/=rval; break; default: cout<<"answer: "<<lval; return 0; } } cin.get(); return 0; }