Do while loop buggy [Need helps]

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
35
36
37
38
int pincode(int chance,int pin){
	int actualPin = 1103;
	if (actualPin == pin){
		chance = chance +1;
	}
	else if (actualPin !=pin) {
		
		
		cout << " Wrong pin code enter, Please enter again. You have "<< chance <<" time chance left ";
		chance = chance - 1;
		
		system("pause");
	}
	
	return chance;
}
int main (){
do{
	system("cls");
	cout << "\t\t\t\t   WELCOME\n\t\t\tPLEASE ENTER YOUR PIN NUMBER\n";
	cin >> pin ;
	chance = pincode (chance,pin);
	
	
	}while ((chance != 4)||(chance!=0));
	// process to next if the pass is 4
	if (chance ==4 ){
		cout << "wait";
		system("pause");
	}

	// exit the pin in due to attemp tried 3 times
	else if (chance ==0){
		cout << "Sorry, you've tried 3 times and failed to login with the PIN\n";
	}

}



Here is my coding, but however, whenever my chance reach 4 or 0, it still looping ,it wont go through the next step....
how to solve this bug...
This condition (chance != 4)||(chance!=0) is equivalent to true, because a number cannot be equal to 0 and 4 at the same time. What you need to change it to is (chance != 4)&&(chance!=0).

That's pretty much it :)
Last edited on
Topic archived. No new replies allowed.