twitter
    Find out what I'm doing, Follow Me :)

Additional Compare Concepts

The third group of compares will introduce some additional concepts, namely the logical "AND" and the logical "OR". We assign the value of 77 to the three integer variables simply to get started again with some defined values. The first compare of the third group contains the new control "&&", which is the logical "AND". The entire statement reads, if "x’ equals "y" AND if "x" equal 77 then the result is "true". Since this is true, the variable z is set equal to 33. The next compare in this group introduces the "||" operator which is the "OR". The statement
reads, if "x" is greater than "y" OR if "z" is greater than 12 then the result is true. Since "z" is greater than 12, it doesn’t matter if "x" is greater than "y" or not, because only one of the two conditions must be true for the result to be true. The result is true, so therefore "z" will be assigned the value of 22.