It's just a little nooby problem. In my book it said to try and design a program that would take two numbers and add or subtract them (With input from the user). Anyway this is what I tried to do:
Code:
void main()
{
int no1, no2;
char plusminus;
cout << "\n- Please enter 2 integers to be added or subtracted -";
cout << "\n\nNumber 1: ";
cin >> no1;
while(plusminus != '+' || plusminus != '-')
{
cout << "\n\nWould you like to add or subtract? (+/-): ";
cin >> plusminus;
switch(plusminus)
{
case '+':
plusminus = '+';
break;
case '-':
plusminus = '-';
break;
default:
cout << "\n\nERROR: That is not an option.\n";
}
}
cout << "\n\nNumber 2: ";
cin >> no2;
if(plusminus == '-')
cout << endl << no1 << " " << plusminus << " " << no2 << " = " << no1 - no2;
else
cout << endl << no1 << " " << plusminus << " " << no2 << " = " << no1 + no2;
}
The problem is when you try and select whether it's plus or minus it just loops even if you select + or -...
Thanks very much if you can help.
-Marlon