Next: Logical Operators Up: Basic C Programming Previous: Arithmetic Operations

Comparison Operators

To test for equality is ==

A warning: Beware of using ``='' instead of ``=='', such as writing accidentally

if ( i = j ) .....

This is a perfectly LEGAL C statement (syntactically speaking) which copies the value in "j" into "i", and delivers this value, which will then be interpreted as TRUE if j is non-zero. This is called assignment by value - a key feature of C.

Not equals is:

Other operators < (less than) , > (grater than), <= (less than or equals), >= (greater than or equals) are as usual.
Fri May 20 13:40:49 BST 1994