208 Day 06 Selection2

208 Day 06 Selection2 - 4002-208 Intro. to Prog. [in C+]...

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

View Full Document Right Arrow Icon
4002-208 Intro. to Prog. [in C++] Day 06 More on Selection
Background image of page 1

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

View Full DocumentRight Arrow Icon
Expanded Conditions The condition of an if statement can contain the Boolean operators And && Or || Not ! 2 4002-208
Background image of page 2
Truth Table for And Operator Given a condition b1 && b2 where b1 and b2 have a Boolean value, the result of the And operator is shown in the following table b1 b2 b1 && b2 False False False False True False True False False True True True 3 4002-208
Background image of page 3

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

View Full DocumentRight Arrow Icon
Example of And Operator Test to see if x is between 1 and 22, inclusively if ( x >= 1 && x <= 22) The relation condition x >= 1 is evaluated (T or F) and then x <= 22 is evaluated (T or F). The And operator is applied. Test to see if t is between 4 and 12, exclusively if ( t > 4 && t < 12) 4 4002-208
Background image of page 4
Comment on And Operator As in English, both Boolean conditions must be true for the total expression to be True. C++ uses lazy evaluation, that is, if the first Boolean expression is False (here represented by b1), the second expression is not evaluated as the result of the expression must be False. 5 4002-208
Background image of page 5

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

View Full DocumentRight Arrow Icon
Truth Table for Or Operator Given a condition b1 || b2 where b1 and b2 have a Boolean value, the result of the And operator is shown in the following table b1 b2 b1 || b2 False False False False True True True False True True True True 6 4002-208
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/31/2009 for the course NSSA 4002 208 taught by Professor Niemi during the Spring '09 term at RIT.

Page1 / 24

208 Day 06 Selection2 - 4002-208 Intro. to Prog. [in C+]...

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

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