Do while loop problem

This function is part of a bigger program. I am having trouble because everything I write after a do while loop will not execute. The return statement satisfies the compiler but it doesn't actually execute. It's designed to jump to another function. Any help on why the code after the do while loop won't execute?

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
  char AR_one()
{
	cout << "Okky dude, we're outside the Alkion Ruins! CAN YOU BELIEVE IT!?\n";
	cout << "(1)Yes, I can believe it.\n(2)No, it's absolutely unbelievable.\n";
	int YorN = 0;
	do
	{
		cin >> YorN;

		if (YorN == 1)
		{
			cout << "HAHA YEAH! Let's go in! Watch your step." << endl;
		}

		else if (YorN == 2)
		{
			cout << "Well what's wrong with you? It's totally believable...\n";
			cout << "Anyway let's go in" << endl;
			
		}
		else
			cout << "Dude tell me straight what's yo problem?" << endl;
	} while ((YorN != 1) || (YorN != 2));

	cout << "This line won't execute and I don't know why!" << endl;
	return directionchoice();
};
}while ((YorN != 1) &&(YorN != 2));
Last edited on
You do continue the loop as long as YorN is not 1 or YorN is not 2.
Take value that is not 1 or 2. Condition is obviously true.
Take 1. YorN is not 2 and thus condition is true.
Take 2. YorN is not 1 and thus condition is true.

Boolean OR is true if at least on side is true.
Boolean AND is true only when both sides are true.
Thanks you dudes! I'm horrible with logical operators I always get it the exact opposite.
Topic archived. No new replies allowed.