CyberSlug Rules!

Beginner Programming CMPS060

Prof. Paulo Franca

Home

Syllabus

Login

Objects

Download

Staff only

C++ Complex conditions:

Conditions can be combined using the logical operators:

! (not) && (and) || (or)

Priority is: not, and , or. Always enclose each condition in parentheses!

general syntax:

(<condition>) <logical operator> (<condition>)

examples:

note:

C++ allows any expression to be used in place of a condition!

ex: (avoid doing this!!!)

if( x = 0 ) .... this will always be false! x will be made equal to zero.
if ( x==0 ) ... this will depend on the value in x.