Help with coding

I'm working on the code for a conversation, here's what I have so far:

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>

using namespace std;

int main ()
{
    string i;
    char response;
    cout << "Hello. What is your name?\n";
    cin >> i;
    cout << i << " is a horrble name.\n";
    cout << "How many friends do you have?\n";
    cin >> i;
    cout << i << "? That seems like an abnormally small amount.\n";
    cout << "Have you ever contemplated suicide?\n";
    cin >> response;
    if (response == 'y' or 'Y')
    {
     cout << "Well maybe you should go through with it.\n";
     system("pause");
    }
    else if (response == 'n' or 'N')
    {
     cout << "Well maybe you should reconsider.\n";
     system("pause");
    }
    {
    cout << "Do you want to play a game?\n";
    cin >> response;
    if (response == 'y' or 'Y')
    {
     cout << "Okay, here are the rules:\n";
     system("pause");
     cout << "Rule 1: You are a horrible person.\n";
     system("pause");
     cout << "Rule 2: You lose.";
     system("pause");
     cout << "Goodbye.\n";
    }
    else if (response == 'n' or 'N')
    {
     cout << "Well you suck, and you would have lost anyways.\n";
     system("pause");
     cout << "Goodbye \n";
    }
}
    system("pause");

    return 0;
}


After the "Do you want to play a game?", when I run the program, it doesn't let me type in an answer, it just skips to the "Okay here are the rules" in the if (response == 'y' or 'Y') area. What am I doing wrong?
The expression in the if statement is always equal to true.

if (response == 'y' or 'Y')

You shall change it to

if (response == 'y' or response == 'Y')
Last edited on
Okay thank you. This is my first time coding and that was the ghetto way I found to make sure the users input didn't have to be case sensitive.
Topic archived. No new replies allowed.