Help with While loop

May 10, 2014 at 4:04pm
Can someone tell me why my while loop at the end always triggers an "invalid response" even though it does equal "y or n" (Note I did add a cout after the cin to verify that the response does = y or n (this does not need to be there)
1
2
3
4
5
6
7
8
	       cout << endl << "Would you like to see the divisors of another integer (y/n)?"; 
	        cin >> response;
			cout << response;
	      while (response != 'y' && response != 'n');
		 {
			 cout << "Please respond with Y (or y) for yes and N (or n) for no. ";
			 cin >> response;
		 }
May 10, 2014 at 4:14pm
anyone?
May 10, 2014 at 4:16pm
What is the type of 'response'?
May 10, 2014 at 4:28pm
while (response != 'y' && response != 'n'); <-- remove the semicolon
May 10, 2014 at 4:45pm
weird.. VS was "expecting a semicolon" so I added it.. then after closing and re-opening when I removed it, everything functions fine. Thanks blue!
May 10, 2014 at 4:49pm
kesk it's a "char"
Topic archived. No new replies allowed.