calc2 - res=lval+rval; else if(op=='-') res=lval-rval; else...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <math.h> #include <iostream> # using namespace std; u int main() { cout<<"please enter expression (we can handle +,-,*, and /):\n"; int lval; int rval; char op; int res; cin>>lval>>op>>rval; while(cin>>lval>>op>>rval) { if(op=='+')
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: res=lval+rval; else if(op=='-') res=lval-rval; else if(op=='*') res=lval*rval; else if(op=='/') res=lval/rval; else if(op=='^') res=pow(lval,rval); r cout&lt;&lt;&quot;Result:&quot;&lt;&lt;res&lt;&lt;'\n'; } return(0); r }...
View Full Document

Ask a homework question - tutors are online