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 |
false |
true |
false |
true |
false |
true |
false |
false |
false |
false |
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
(B) a && !b
(C) !(!a || b)
The expression evaluates to true if and only if a is true and b is false.
a && !b
This is one of the answer choices.
Factor a ! from the entire expression (which is a silly thing to do here, but can be done).
!(!a || b)
This is the other correct answer choice.