Conditions, Logical Expressions, and Selection Control Structures

 

I.  Flow of Control

A.  Selection

II.  Conditions and Logical Expressions

A.  Logical Expressions

1.  Boolean Data

2.  Relational Operators

3.  Logical Operators

4.  Short-Circuit Evaluation

B.  Precedence of Operators

C.  May We Introduce: George Boole

D.  Software Engineering Tip: Changing English Statements Into Logical Expressions

E.  Relation Operators With Floating Point Types

III.  The If Statement

A.  The If-Then-Else Form

B.  Blocks (Compound Statements)

C.  Matters of Style: Braces and Blocks

D.  The If-Then Form

E.  A Common Mistake

IV.  Nested If Statements

A.  The Dangling Else

V.  Testing the State of an I/O Stream

VI. Testing and Debugging

A.  The Problem Solving Phase: The Algorithm Walk-Through

B.  The Implementation Phase

1.  Code Walk-Through

2.  Execution Trace

3.  Testing Selection Control Structures

C.  Tests Performed Automatically During Compilation and Execution

D.  Testing and Debugging Hints

VII.  Summary