The relational operators are: > (greater than), >= (greater than or equal to), < (less than) and <= (less than or equal to). They all have the same precedence. The equality operators: == (equal to) and != (not equal to) are just below the relational operators in precedence.
Relational operators have lower precedence than arithmetic operators, so an expression like i < j + 1 is same as i < (j + 1).
&& (logical and) and || (logical or) are logical operators. Expressions connected by these operators are evaluated from left to right and evaluation stops as soon as the truth or falsehood of the result is known.
In a previous example code, we saw the following:
for(i = 0; i < max_len - 1 && (c = getchar()) != EOF && c != '\n'; i++) line[i] = c;
Before reading the next character, we first check if we have room to store it in the array. If i < max_len – 1 test fails, the condition on the right of && is not evaluated, which means we don't read another character and check for EOF or `\n`.
The numeric value of a relational or logical expression is 1 if the relation is true and 0 if the relation is false.
The unary negation operator ! converts a non-zero operand into 0 and a zero operand into 1. A common use of !:
if (!flag)
rather than writing
if (flag == 0)