
do,while problems
here is my code:
Code:
int menu(void)
{
int answer = 0;
do {
cout << "Menu" << endl
<< "1 Add two fractions" << endl
<< "2 Multiply two fractions" << endl
<< "3 Exit the program" << endl
<< "Please select an option (1, 2, or 3): ";
cin >> answer;
} while (answer != 1);
return answer;
}
for some reason when i change,
Code:
} while (answer != 1);
// to this
} while (answer != 1  2);
// or this
} while (answer != '1'  '2');
i can not seem to get the loop to stop once the correct answer is input.
I have looked at both the do, while and  operator and cant seem to find where the problem is because it causes no errors.
Thanks to anyone that can help.

You can't say (answer == a  b).
You have to do each one on its own:
Code:
while ( (answer != 1) && (answer != 2) )
When the answer is either 1 or 2, the while loop will end.
