If statement help

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
if (choice == "Yes")
	{
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".\n";
		cout << "You got shot.";
		cin.get();
	}

	else if (choice == "No")
	{
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".\n";
		cout << "As you turn away from the street you hear gunshots.";
		cin.get();
	}

	else if (choice != "Yes, No")
	{
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".\n";
		cout << "What did you say?";
		cin >> choice;
	}

how would i get the program to go back to a previous statement after entering a correct value here?
1
2
3
4
5
6
7
8
9
10
11
else if (choice != "Yes, No")
	{
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".";
		Sleep (wait);
		cout <<".\n";
		cout << "What did you say?";
		cin >> choice;
	}
Use a loop.

1
2
3
4
while (choice != "yes" && choice != "no")
{
    //if else statements here...
}
Last edited on
thank you sir
Use while or do-while statement.
Topic archived. No new replies allowed.