7.5 Compound Conditions


7.5 Compound Conditions

More complex expressions can be constructed with the logical operators and, or, and not. These logical operators help to join two or more simple conditions to construct conditions that are more complex.

The general structure of a compound condition using the or operator and two simple conditions, cond1 and cond2, is:

          cond1 or cond2 

The other two logical operators are used in the same manner. For example,

        if a ! = b and x > 0        then                         statements_1         else                         statements_2         endif 

This same compound condition can be constructed in a more verbose manner. For example:

        if a not equal b and x greater than 0 

The following expression uses the not operator:

        not (x <= y) 

This expression has the following descriptive meaning: it is not true that x is less than or equal to y.




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net