lect05 Logical Operators and Switch

lect05 Logical Operators and Switch - Exam 1 Exam 1 Next...

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

View Full Document Right Arrow Icon
Exam 1 Exam 1 Next Week
Background image of page 1

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

View Full DocumentRight Arrow Icon
Quiz 1 54 Quizzes Taken Average: 38.63 Median: 41 3 Perfect Scores
Background image of page 2
if ” Conditions Syntax: if ( condition )   //MUST HAVE ()!! { statement(s) ; //BODY } condition Must Evaluate to “True” or “False” Two Types of Operators for Conditionals: Relational: < , > , >= , <= Equality: == , !=
Background image of page 3

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

View Full DocumentRight Arrow Icon
else Statement Syntax: if ( condition )   { statement(s) ; //condition true } else { statement(s) ; //condition false }
Background image of page 4
if-else Example if (myGrade >= 60) { cout << “You passed!” << endl; } else { cout << “How about them Cubs?” << endl; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Nested if Statements if (myGrade >= 80) if (myGrade >= 90) cout << “You have an A!” << endl; else cout << “You have a B!” << endl; else cout << “We’ll give you a C.” << endl;
Background image of page 6
if / else (Cascaded) Sequence of if / else Statements Example: if (myGrade > 90) cout << “A!” << endl; else if (myGrade > 80) cout << “B!” << endl; else if (myGrade > 70) cout << “C!” << endl; else cout << “Oh-oh!” << endl;
Background image of page 7

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

View Full DocumentRight Arrow Icon
B O D Y T R U E B O D Y F A L S E C O N D I T I O N 2 T R U E B O D Y F A L S E C O N D I T I O N 1 Decision Tree – nested if
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

lect05 Logical Operators and Switch - Exam 1 Exam 1 Next...

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

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