plz help me


Hello, I am having this problem with this program that wants me to use a while loop as input validation to ask the user to enter 'Y', 'y', 'N', or 'n'. This is 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
#include <iostream>
using namespace std;

int main()
{
	char letter; //Answer with Y, y, N, or n

	cout << " Would you like to exit this program?\n";
	cout << " Answer 'Y' or 'y' for yes and \n";
	cout << " 'N' or 'n' for no." << endl;
	cin >> letter;

	while(letter != 'Y' || letter != 'N')
	{
		cout << " Choose again:  ";
		cin >> letter;
	}

	cout << " Terminating program...." << endl;
	

	system("pause");
	return 0;
}
Last edited on
Never mind, I figured it out.
Was it the single quotes around while(letter != 'Y' || letter != 'N')?

I think while(letter != "Y" || letter != "N") is what you were looking for.
Topic archived. No new replies allowed.