# True or False.

The concept of an expression evaluating to true or false is one of the corner stones of C. BUT the language derives true and false in an unusual way.

Basicly there is no boolean value. The number 0 is considered to be false and all other numbers are considered to be true....

Please consider the following expressions.

    	(1 == 1) 	true
    	(1 != 1)	false
    	(i  = 1)   	true
    	(i  = 0)   	false
    	(i  = 1 + 1) 	true

The first two examples should be clear but the last ones need explanation .

The last three examples assign a value to a variable and a side effect of assignment is to return the value assigned, it is this value that is tested to be true or false.

Looking at the last example:

    	(i = 1 + 1)
      	(i = 2)
    	(2)

- The third expression assigns a value of 1 to i. 1 is considered to be true because it is non-zero.

- The fourth expression assigns a value of 0 to i. 0 is considered to be false.

- The fith expression assigns a value of 2 to i. 2 is considered to be true, because it is non-zero.

## See Also:

enum keyword

Top | Master Index | Keywords | Functions

Corrections made by Christopher Wolf