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 |
|---|---|---|
true |
true |
true |
true |
false |
false |
false |
true |
true |
false |
false |
true |
Which of the following expressions are equivalent to the value of the expression shown in the table?
Select TWO answers.
(A) !(a && b)
(B) !(a || b)
(C) !(a && !b)
(D) !a || b
Solution
(C) !(a && !b)
(D) !a || b
The expression evaluates to false if and only if a is true and b is false.
Write the expression as if it evaluated to true under the circumstances above.
a && !b
Add a ! outside to make the expression false.
!(a && !b)
This is one of the answer choices.
Distributing the ! yields:
!a || !!b)
!a || b
This is the other correct answer choice.