Exercise 11


#1

I don’t get what I have to do for this exercise\

  1. Use the precedence rules to help you evaluate the Boolean expression in the single line comment above the tricky variable.

Then, set the boolean variable tricky equal to the result (either true or false).

Capture


#2

That expression,

( 3 >= 3 && !(true || true) )

according to precedence, brackets, not, and, or, evaluates in the following order…

outer brackets

Since they enclose the entire expression they are moot and can be removed.

3 >= 3 && !(true || true)

inner brackets

means evaluating TRUE OR TRUE which we know yields, true.

3 >= 3 && !true

!true

which leaves us with,

3 >= 3 && false

and

Owing to short-circuiting, we can immediately conclude the expression is false, regardless the truthiness of the first operand. Technically, the >= operator does have precedence over AND so the operand would be evaluated first, yielding true; however, this is moot.

So we have an outcome of false Now it comes to you to set tricky to that value and follow through with the remaining instruction.


#3

thank you for explaining


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.