Section Quiz (((True || False) && True) || False)

Can someone explain how the expression
(((True || False) && True) || False)

Can evaluate as true ??

I get how Bool work and comparing number, char or string…
But as this standalone expression, I am completely lost as to how this resolves ?
(Logically, without using the compiler)

Thanks !!

True || False = True

True && True = True

So

(((True || False) && True) || False) = (True && True) || False = True || False = True

1 Like

Thank you Sam !

Hi Sam,

I’m confused about how True || False = True.

Maybe I’m looking at this too literally, as this reads to me True or False = True which I don’t understand why this is the case?

I do understand how if True || False = True then how the string comes to equal true, I’m just struggling to understand why True || False = True in the first place.

Thanks!

I believe that, despite my lack of knowledge regarding C++, my basic knowledge of JavaScript may be able answer this confusion.

My understanding (At least, this was the case in JavaScript), is that the statement equates to “True” when either side of the Or statement are true.

In other words: True || False. Does True = True? Yes. Does False = True? No. But because True = True, then the statement “True || False” becomes true.

Hi GrimCreaperr (I’m hoping that’s your real name),

Thanks for getting back to me. Okay, I can accept that as a rule going forward. That clears things up - thanks a lot!

1 Like

Take a look at these truth tables for more information: https://en.wikipedia.org/wiki/Truth_table

Hey Sam,

Thanks for this - shall take a closer look over this. Do love some maths and logic!

1 Like

Sorry if my grammar is not correct because I’m not American. OR, AND are the basis in the math.
OR means one of them is correct then the expression is correct
AND means both of them must be correct then the expression is correct. Otherwise, the expression is incorrect

3 Likes

Nice and concise explanation Rhen_Su. Thank you for simplifying this so we don’t have to pour over logic tables to understand it!

Privacy & Terms