Help with do while loops

For some reason this loop is repeating no matter what the user inputs, also the while loop runs every time. I know the while loop isn't needed and their are easier ways to do it but i'm just learning and practicing some of the thing i'm learning
1
2
3
4
5
6
7
8
9
10
11
12
        do{
            cout << "\n[Y]es | [N]o\n";
            cin >> done;

            while((done!='Y') || (done!='N') || (done!='n') || (done!='y'))
            {
                error();
                break;
            }

        }while((done!='Y') || (done!='N') || (done!='n') || (done!='y'));
you could use an if statement instead of the inner while loop; i.e
1
2
3
4
if while((done!='Y') || (done!='N') || (done!='n') || (done!='y'))
{
    error();
}


Good Luck, Zaki
Dreilly wrote:
For some reason this loop is repeating no matter what the user inputs, also the while loop runs every time

The reason is this:
 
while((done!='Y') || (done!='N') || (done!='n') || (done!='y'))


This part must be:
 
while(done != 'Y' && done != 'N' && done != 'y' && done != 'n')
Topic archived. No new replies allowed.