View Single Post
Old 12-03-2008   #5
Tawa
 
Tawa's Avatar
 
Last Online: 08-02-2018
Join Date: Mar 2006
Posts: 6,245
Thanks: 2,120
Thanked 3,365 Times in 1,740 Posts
Groans: 29
Groaned at 44 Times in 35 Posts
Default Re: c++ guru, urgent plz

Code:
int x, y;
char z;
 
cin >> x;
while(1){
   cin >> z;
   if(z != '+' && z != '-')
       break;
   cin >> y;
   if(z == '+')
       x+=y;
   else if(z == '-')
       x-=y;
}
if(z != '=')
    cout << "Syntax Error" << endl;
else
    cout << "The Result Is: " << x << endl;
This Should Do The Work.
__________________
What we do in life, echoes in eternity.
Tawa is offline   Reply With Quote
The Following User Says Thank You to Tawa For This Useful Post:
sciencedoor (12-03-2008)