Logical Connectors

These are the usual And, Or and Not operators.

They are frequently used to combine relational operators, for example

x < 20 && x >= 10

In C these logical connectives employ a technique known as lazy evaluation. They evaluate their left hand operand, and then only evaluate the right hand one if this is required. Clearly false && anything is always false, true || anything is always true. In such cases the second test is not evaluated.

Not operates on a single logical value, its effect is to reverse its state. Here is an example of its use.

if ( ! acceptable )
        printf("Not Acceptable !!\n");

  Go to Comparison     Go to Index               Go to Summary