Why is my c != 'o' || c != 'x' condition always true? [duplicate]
This question already has an answer here: Why non-equality check of one variable against many values always returns true? 3 answers I have this loop statement, which I'll express using C-like syntax (C, C++, Java, JavaScript, PHP, etc. all use similar syntax): while (c != 'o' || c != 'x') { c = getANewValue(); } I want it to run until I get a 'o' or 'x' , but it never exits, even when c is 'o' or 'x' . Why not? I've also tried using if : if (c != 'o' || c != 'x') { // Show an error saying it must be either 'o' or 'x' } but that also always shows the error message, even when c is 'o' or 'x' .