Return value of “==” operator in C

Can I assume that in C, the “==” operator will always evaluate to 1 if the two values are equal or it can evaluate to other “true” values?

Yes, and so does != > < >= <= all the relational operator.

C11(ISO/IEC 9899:201x) ยง6.5.8 Relational operators

Each of the operators < (less than), > (greater than), <= (less than or equal to), and >=
(greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is
false.107) The result has type int.

Leave a Comment