Presentation is loading. Please wait.

Presentation is loading. Please wait.

Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%

Similar presentations


Presentation on theme: "Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%"— Presentation transcript:

1 Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%

2 Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else): Control Proceeds Dependent on Conditions Iteration (looping): Control Repeated until Condition Met

3 C++ if Statement Syntax Syntax if ( condition ) statement ; If Condition Is True, Statement Is Executed If Condition Is False, Statement Is Not Executed If Multiple Actions Are Required for Statement, a Compound Statement Must Be Used: if ( condition ) { statement ; }

4 Conditional Operators Relational Operators:, >=, <= Equality Operators: ==, !=

5 Selection Examples if (age < 30) cout << “You are very very Young” << endl; if (grade == ‘A’) cout << “Congratulations!” << endl; if (grade != ‘F’) cout << “You passed!” << endl;

6 else Statement Syntax: if ( condition ) { statement(s) ; //condition true } else { statement(s) ; //condition false }

7 if-else Example if (myGrade >= 60) { cout << “You passed!” << endl; } else { cout << “How about them Cubs?” << endl; }

8 Compound Statements Compound Statement: One or More Statements within a Set of Curly Braces Must Use Compound Statement if More than One Statement Is Supposed to be under Control of if or else Conditional Include Curly Braces after if so if other Statements Are Added in Future, Curly Braces Are Already There


Download ppt "Announcements Quiz 1 Posted on blackboard Handed Back (and Gone Over)Next Monday “Only a Quiz” Counts 5% of Final Grade Exam 1 Counts 10%"

Similar presentations


Ads by Google