|
-
Jan 31st, 2003, 01:44 AM
#1
Thread Starter
Lively Member
While Loop Problem!!pls Help
hello friends...
In the C++ program below..there is something wrong in the While Loop. logic.What i want is that when we type
the letters --> y,Y,n or N then the program should exit.,else
it should not exit and then print as in the cout.
But the code is not working for me.it doesnt not exits even if when we enter --> y,Y,n or N.
Plss check the while loop and reply me with modifications
Thanx in advance
Prasad
Here is the code below:--
#include<iostream.h>
main()
{
char answer;
while ( (answer != 'y') || (answer != 'Y') || (answer != 'n') || (answer != 'N') ) //error checking for answer
{
cout << "Illegal character. Please enter again." ;
cin >> answer ;
} }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|