Which of the following will evaluate to true only if boolean expressions A
, B
, and C
are all false
?
Answer:
!(A || B || C)
My answer:!(A && B && C)
Why is my answer incorrect? If A
, B
and C
are all false
and the !
is distributed, it will make all of them true
, thus returning true
.
Given that a
, b
and c
are integers, consider the boolean expression
(a < b) || !((c == a * b) && (c < a))
Which of the following will guarantee that the expression is true
?
Answer:
c < a
isfalse
Doesn't the result rely on (c == a * b)
being false
also because of the &&
?
Keyword: only. If at least one of A
,B
or C
is true
, then !(A || B || C)
will be false
(since A || B || C
will be true
and ! true
is false
).
Doesn't the result rely on
(c == a * b)
being false also because of the&&
?
No: If c < a
is false
, then (c == a * b) && (c < a)
must also be false
, meaning that the expression ! ((c == a * b) && (c < a))
must be true
, implying that the entire expression must be true
(because of the ||
, and the fact that we already know right-hand side will be true
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With