Logical Expressions
Several of C's statements,
including the if statement, must test the value of an expression to see if it
is “true” or “false.” For example, an if statement might need to test the
expression i < j; a true value would indicate that i is less than j. In many
programming languages, an expression such as i < j would have a special “Boolean”
or “logical” type. Such a type would have only two values, false and true. In C, however, a comparison such
as i < j yields an integer: either 0 (false) or I (true). With this in mind,
let's look at the operators that are used to build logical expressions.
No comments:
Post a Comment