1. ## Not grasping Booleans

Hi,
Im very new to programming and Im liking the way this website is explaining c but I'm having some trouble understanding booleans.

An example is listed as follows:
!( 1 || 0 ) ANSWER: 0

to me this reads Not 1 or 0
so if the the value is not 1 or 0, how is the answer 0?

3. Evaluate !(1 && !(0 || 1)).
A. True
B. False
C. Unevaluatable

The answer is listed as "A true", but why? Doesnt this statement have to be compared to something in order to be true or false?

2. Zero or one is true, which in C means non-zero. The negation of that is false which in C means a zero value.

So, to sum up: anything != 0 evaluates to true
0 evaluates to false

Note, that there is an actual bool type defined in stdbool.h which was introduced in C99 I believe, however most old school C programmers don't use it, because "it's not the proper way to write C "

3. Originally Posted by esmelogo
An example is listed as follows:
!( 1 || 0 ) ANSWER: 0

to me this reads Not 1 or 0
so if the the value is not 1 or 0, how is the answer 0?
The result of (1 || 0) is 1. The result of !1 is 0.

Originally Posted by esmelogo