if statements not triggering with text strings

Hello! I'm having trouble with strings triggering if statements, please help me understand this because I am at my wits end :(

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()
{
string play_game;




cout<<"Would you like to play a dice game? yes/no"<<endl;
cin>>play_game;

if(play_game == "yes"||"YES"||"Yes"||"y"||"Y"){

cout<<"This triggers the if statement"<<endl;
}

else if(play_game == "no"||"No"||"NO"||"n"||"N"){
cout<<"This triggers the else if statement"<<endl;
}

else{
cout<<"This triggers the else statement";
}


}

if(play_game == "yes"||"YES"||"Yes"||"y"||"Y")
Should be instead:

if (play_game == "yes" || play_game == "YES" || play_game == "Yes" || play_game == "y" || play_game == "Y")



Such a blunder. I must have debugged for hours on this. Still learning I guess. Thanks!
Topic archived. No new replies allowed.