![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Recall that C's if
statement executes its
embedded statement if the value of the Boolean expression is not
0
. C has no complimentary statement, which might be called
unless, if it existed, for which the embedded statement is executed
when the value of the Boolean expression is 0.
One way to get the effect of the nonexistent unless statement is by
prefacing the Boolean expression with the not operator, !
. Thus,
the following tests are equivalent:
if (ratio < 10) printf ("It is cheap!\n"); if (!(ratio >= 10)) printf ("It is cheap!\n");