In order for the old logic to work, we need to make sure the two conditions do not get evaluated in the same conjunction or disjunction.
The solution involves the use of a boolean variable. A boolean variable is like any variable, has a name and a value. The only important is that instead of storing a numerical value, a boolean variable stores a boolean (true or false) value.
Listing 3 is a revised algorithm that works without short circuited evaluation.
Trace this code with the test case in the previous subsection, and you should see how this logic works.