1_Review_5-1 - 1 CIS 15AG Review Chapter 5: Selection...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 15AG Review Chapter 5: Selection – Making Decisions Logical expression an expression that can be either true or false . Logical expressions are created using relational and/or logical operators. Relational Operators: < <= > >= == != Logical Operators: Evaluation of logical expressions complement of == is != !(a == b) is a != b complement of < is >= !(a < b) is a >= b complement of > is <= !(a > b) is a <= b complement of && is || !(a && b) is ! a || !b (De Morgan's Rule) !(a || b) is ! a && !b Precedence/ Associativity Arithmetical Operators Relational Operators Logical Operators Assignment Operators 15 Right to left + plus - minus ! 14 Left to right * / % 13 Left to right + - 10 Left to right < <= > >= 9 Left to right == != 5 Left to right && 4 Left to right || 2 Right to left = += -= *= /= %= Expressions connected by && and/or || are evaluated left to right, and it is guaranteed that the evaluation will stop as soon as the truth or falsehood is known. n != 0 && a / n > 10 // when n is 0, a / n > 10 is not evaluated, because false and anything is false Two-Way Selection – a logical expression is evaluated; if it is true, one or more actions is/are executed, if it is false, another action or group of actions is executed. 1 not false true true false and false true false false false true false true or false true false false true true true true b b - a a > b a
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 5

1_Review_5-1 - 1 CIS 15AG Review Chapter 5: Selection...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online