Loop problem

Hi, i am having a bit of trouble looping a program. The program keeps looping even if i entered 1 or 0 for the variable repeat.Hope you guys are able to help me out.Thanks

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
28
29
30
31
32
33
34
# include <iostream>
using namespace std;

int main()
{
    int a, b, c, repeat;
    
    do
    {
      .... //some if and else statement
      
      cout<< "Do you want to compare another? (yes=1,no=0) "; cin>> repeat;

      
      if(repeat!=1 || repeat!=0)
      {
       cout<< "Bad input. Do you want to compare another? (yes=1,no=0) "; cin>> repeat;
       
       while(repeat!=1 || repeat!=0)
       {
         cout<< "Bad input. Do you want to compare another? (yes=1,no=0) "; cin>> repeat;
         cin.get();
       }
      }
      else{}
    }
    
    while (repeat==1);
    
    cin.get();
    cin.get();
    
    return 0;
}
|| returns true if at least one of the sides are true. This means that the only way to get false is if both sides are false.
If repeat!=1 is false then repeat!=0 must be true and vice versa so there is no way the loop condition can be false.
Oh right, i messed up the logical operators. Thanks.
Topic archived. No new replies allowed.