{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Ch2_5 - 1 Section 2.5 Conditional Statements Boolean...

This preview shows pages 1–6. Sign up to view the full content.

Next Previous Section 2.5: Control statements 11 ® Boolean operators ® Control statement blocks ® if ® else if ® else Section 2.5: Conditional Statements

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Next Previous Section 2.5: Control statements 22 Boolean operators The nine Boolean operators < less than <= less than or equal to > greater than > = greater than or equal to = = equal to (easily forgotten – don’t use one = sign, or the consequences will be severe!) ! = does not equal && and (easily forgotten)
Next Previous Section 2.5: Control statements 33 Two examples (1,2) x = 1; y = 2; z = 3; if (x<y) a=5; if (y<z) b=5; if (z>y && y>x) a=1; if (z<y || x<y) b=1; if (z != x) b=2; // what do a and b equal? x = 1; y = 2; z = 3; if (y<x) { a=5; b=5; } else if (z>y && y>x) { a=2; b=1; } else { a = 3; b = 3; } // what do a and b equal? a=1 and b=2 a=2 and b=1 X X control_block_1.cp p control_block_2.cp p

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Next Previous Section 2.5: Control statements 44 A compound conditional statement if ( ( (x<y)&&(y>z) )||( (z>x)&&(y>x) )||( (x<z)&&(y>z) ) ) Is this true or false? x = 1; y = 2; z = 3; T T T T F F F T F T an d an d an d o r o r control_block_compound.cp p
Next Previous Section 2.5: Control statements

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 10

Ch2_5 - 1 Section 2.5 Conditional Statements Boolean...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online