Why do the following operators work like this?
10 == 10 || 10 != 10 && 10 < 10 -> true
but why? Isn't the priority as shown below and doesn't it start from the left side?
true && false ?
(10 == 10 || 10 != 10) && (10 < 10)
I expected it to be false but it was true!
*Update: This is the same for all languages
CodePudding user response:
&& has higher precedence than ||, at least for c . Note that not all languages have the same operator precedence rules.
So, your expression is evaluated as 10 == 10 || (10 != 10 && 10 < 10)
, which is true