Exercise
The following table shows the value of an expression based on the values of a and b.
Value of a |
Value of b |
Value of expression |
|---|---|---|
false |
false |
false |
true |
false |
true |
false |
true |
true |
true |
true |
false |
Which of the following expressions is equivalent to the value of the expression shown in the table?
(A) (a && b) || (!a && !b)
(B) (a || b) && (!a || !b)
(C) (a || !b) && (b || !a)
(D) (a || !b) || (b || !a)
Solution
(B) (a || b) && (!a || !b)
The table shows an expression that is true when exactly one of a and b is true (and the other is false).
This means at least one of a and b must be true.
a || b
&&
at least one of a and b must be false.
!a || !b
Combine both parts.
(a || b) && (!a || !b)