Chapter 10

7/12/99


Click here to start


Table of Contents

Chapter 10

Flow of Control

Selection: ‘if’ construct

‘if’ construct

Compound-statement Action

Flags

Naming a Flag

Nested ‘if’ statement

Short-circuit evaluation

Short-circuit evaluation

Complementing a Condition

DeMorgan’s Theorem

DeMorgan’s Theorem

Common Mistakes

Common Mistakes

Common Mistakes

Common Mistakes

Common Mistakes

‘if-else’ construct

‘if-else’ construct

‘if-else’ construct

Style

Removing common statements

Removing common statements

Logical assignment for Flags

Logical assignment for Flags

Nested ‘if-else’ statements

Nested ‘if-else’ statements

Nested ‘if-else’ statements

Nested ‘if-else’ statements

Nested ‘if-else’ statements

Common Mistakes

Conditional Operator (?:)

Conditional Operator (?:)

Conditional Operator (?:)

‘switch’ construct

‘switch’ construct

‘switch’ construct

Repetition Structure

‘while’ construct

‘while’ construct

‘while’ construct

‘while’ construct

‘while’ construct

Counter-control repetition

Sentinel-control repetition

‘do-while’ construct

‘do-while’ construct

Flag-controlled loops

‘for’ construct

‘for’ construct

‘for’ construct

‘for’ construct

‘for’ construct

‘for’ construct

‘for’ construct

Common Mistakes

Common Mistakes

‘break’ statement

‘continue’ statement

Nested loops & combined structures

Nested loops & combined structures

Nested loops & combined structures

Homework

Author: Aaron Tan

Email: tantc@comp.nus.edu.sg

Home Page: http://www.comp.nus.edu.sg/~tantc