{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect05 Logical Operators and Switch

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

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

Exam 1 Exam 1 Next Week

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

View Full Document
Quiz 1 54 Quizzes Taken Average: 38.63 Median: 41 3 Perfect Scores
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: == , !=

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

View Full Document
else Statement Syntax: if ( condition )   { statement(s) ; //condition true } else { statement(s) ; //condition false }
if-else Example if (myGrade >= 60) { cout << “You passed!” << endl; } else { cout << “How about them Cubs?” << endl; }

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

View Full Document
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;
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;

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

View Full Document
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
Boolean Type

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 / 19

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

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

View Full Document
Ask a homework question - tutors are online