While statement not working?

前端 未结 2 1438
北恋
北恋 2021-01-29 12:43
#include 
#include 
using namespace std;
int main()
{
    int number;
    float cost;
    char beverage;

    bool validBeverage;

    cou         


        
2条回答
  •  走了就别回头了
    2021-01-29 12:52

    Take this condition as an example, the same problem is in others as well.

    while (beverage!='e'||beverage!='E');
    

    A character is either not equal to 'e', or it is equal to 'e', in which case it's not equal to 'E', so the condition is always true.

    What you want is logical and.

提交回复
热议问题