ASAPMATLAB a false and b true when I compute the a b a

ASAP!!MATLAB

a = false and b = true;

when I compute the (a || b) == a && b, it\'s 0.

However when I evaluate by myself it should be 1. Can any one tell me?

Solution

It\'s because of precedence.

The expression will be computed as followed.

first ~(a||b) is computed, which is true

then true == ~a is evaluated which is false.

then false && ~b. which is false.

hence the output is zero.

add a paranthesis to the code to get the desired output as followed.

~(a||b) == (~a && ~b)

output is 1.

ASAP!!MATLAB a = false and b = true; when I compute the (a || b) == a && b, it\'s 0. However when I evaluate by myself it should be 1. Can any one tell

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site