The relational and equality operators are left-associative in C. Consequently, C, unlike many other languages, allows chaining of relational and equality operators. The C standard, Section 6.5.8, paragraph 6, footnote 107 [ISO/IEC 9899:2011], says:
The expression
a<b<c
is not interpreted as in ordinary mathematics. As the syntax indicates, it means(a<b)<c
; in other words, "ifa
is less thanb
, compare 1 toc
; otherwise, compare 0 toc
."
...