
quick question
reviewing for my final and my professor posted some example questions that might be on the test i know you guys on here dont help with homework but this isnt homework just a question of what you guys think is the right answer since he does not post the answers... the question:
Which of the following is logically equivalent to the Boolean expression
(val != 0  val != 1) ?
a) val >= 0 b) val <= 2 c) 0 d) 1 e) none of the above
personally i think its none of the above by i just want to make sure im studying the right concepts well thanks for the help

I vote d.
Find a value for val that will NOT produce 1. ;)
Alternatively, find a way for both expressions to ever be false. If val is 0, it isn't 1. If it's 1, it isn't 0. There is no way you can make it both not equal to 1 and not equal to 0.... which is the only way you can get 0. Both sides must be 0 for the entire expression to be 0.

i will probably say that all values for val right from 65k to +65k for int val or for long type or any number datatype would go true. so i would say the correct option is not there.
But for me if there is an option all the above or like that then it will go.

The question is about the logical value of the boolean expression, not what values val can take.

sorry i propably misunderstood the question then it is always 1 ie option d

Code:
(val != 0  val != 1)
Is equivalent to:
Code:
!(val == 0 && val == 1)
Since val cannot be both 0 and 1, that is equivalent to !(0) which is 1 (option d).