In: Computer Science
[x, y, and z are integer variables, which expressions are equivalent to each other?]
a. (x==y && x !=z) || (x!=y && x==z)
b. (x==y || x==z) && (x!=y || x!=z)
c. (x==y) != (x==z)
We will be breaking down the following expressions similar to simple englisg statements as follows
1. (x==y && x !=z) || (x!=y && x==z)
In this experssion we see that X is equal to Y and X is not equal to Z. Secondly we see that X is equal to
Z but X is not equal to Y.
Conclusion: So we can conclude that X is equal to Y |Z but not the other
Explanation: Here we can see that in the first case When X is equal to Y it is not equal to Z and vice versa when
X is equal to Z then it is not equal to Y.
2. (x==y || x==z) && (x!=y || x!=z)
In this case we see that X is equal to Y or X is equal to Z and X is not equal to Y or X is not equal to Z
Conclusion: X is eequal to one of the two values and X is not equal to one of the two values
Explanation: Here in this Expression we see that the Left hand side is true if any one ofthe value is true and on
the Right Hand Side is true if any one of the value is not equal to other. but both are required to
true as AND operator is between them
3. (x==y) != (x==z)
Here in this Expression we see thar in Left Hand side X is equal to Y and in the Right hand side we see that
Xis equal to Z but the Left hand side should be complement of Right hand side and Vice Versa.
Conclusion:So we can conclude that X is equal to Y |Z but not the other
Explanation: In the above expression we see that If X is equal to Y then it should be equal to Z and
on the other side if X is equal to Z it should not be equal to Y