int pincode(int chance,int pin){
int actualPin = 1103;
if (actualPin == pin){
chance = chance +1;
}
elseif (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
elseif (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).