How does the C process a conditional statement such as n >= 1 <= 10
?
I initially thought that it would get evaluated as n >= 1 && 1 <= 10
, as it would be evaluated in Python. Since 1 <= 10
is always true, the second porition of the and
is redundant (the boolean value of X && True
is equivalent to the boolean value of X
).
However, when I run it with n=0
, the conditional gets evaluated to true. In fact, the conditional always seems to evaluate to true.
This was the example I was looking at:
if (n >= 1 <= 10)
printf("n is between 1 and 10\n");