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)


See Also:

enum keyword


Top Master Index Keywords Functions


Martin Leslie

Corrections made by Christopher Wolf