#include <iostream>
#include <string>
using namespace std;
int main()
{
string option;
cout << "Would like water, beer, or rum?--> ";
cin >> option;
while( option != "water" || option != "beer" || option != "rum" )
{
cout << "You did not choose a valid option. Try again.\n";
cout << "Would you like water, beer, or rum?-->";
cin >> option;
}
}
Why doesn't this code ever exit the loop even though the user enters the right option?
Read your condition out loud - "run the loop while option is not "water" or option is not "beer" or...".
When should it stop?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With