{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Solutions_Ch05_2_if_else

# Solutions_Ch05_2_if_else - Chapter 5 Chapter...

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

1 5-1 Logical Data and Operators 5-2 Two-Way Selection if…else ? : 5-3 Multi-Way Selection switch else-if 5-4 More Standard Library Functions 5-5 Incremental Development Part II - A Menu Program 5-6 Software Engineering Chapter 5 Chapter 5 Selection—Making Decisions Selection—Making Decisions

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

View Full Document
2 Reading Assignments and Recommended Review Questions, Exercises, and Problems: Reading: 5.2 Two-Way Selection Exercises: 2, 8, 16, 20, 21, 22, 23, 28, 29 9, 10, 24, 25, 26, 27 Problems: 35 through 42, 47, 51 46, 56
3 Computer Science: A Structured Programming Approach Using C 5-2 Two-Way Selection The decision is described to the computer as a The decision is described to the computer as a conditional statement that can be answered either true conditional statement that can be answered either true or false. If the answer is true, one or more action or false. If the answer is true, one or more action statements are executed. If the answer is false, then a statements are executed. If the answer is false, then a different action or set of actions is executed. different action or set of actions is executed. if else and Null else Statement Nested if Statements and Dangling else Problem Simplifying if Statements Conditional Expressions Topics discussed in this section: Topics discussed in this section:

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

View Full Document
4 Computer Science: A Structured Programming Approach Using C FIGURE 5-6 Two-way Decision Logic
5 Computer Science: A Structured Programming Approach Using C FIGURE 5-7 if...else Logic Flow

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

View Full Document
6 Computer Science: A Structured Programming Approach Using C b b - a a > b a a - b true false
7 Computer Science: A Structured Programming Approach Using C if (a > b) a = a - b; else b = b - a; b b - a a > b a a - b true false

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

View Full Document
8 Computer Science: A Structured Programming Approach Using C Table 5-2 Syntactical Rules for if…else Statements
9 Computer Science: A Structured Programming Approach Using C FIGURE 5-8 A Simple if...else Statement

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

View Full Document
10 Computer Science: A Structured Programming Approach Using C b b - a a > b a a - b true false Write a Write b if (a > b) { a = a - b; printf("%d", a); } else { b = b - a; printf("%d", a); }
11 Computer Science: A Structured Programming Approach Using C b b - a a > b a a - b true false Write a Write b if (a > b) { a = a - b; printf("%d", a); } else { b = b - a; printf("%d", a); }

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

View Full Document
12 Computer Science: A Structured Programming Approach Using C b b - a a > b a a - b true false Write a Write b if (a > b) { a = a - b; printf("%d", a); } else { b = b - a; printf("%d", a); }
13 Computer Science: A Structured Programming Approach Using C b b - a a > b a a - b true false Write a Write b if (a > b) { a = a - b; printf("%d", a); } else { b = b - a; printf("%d", a); }

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

View Full Document
14 Computer Science: A Structured Programming Approach Using C FIGURE 5-9 Compound Statements in an if...else
15 a > b a a - b true false Write a if (a > b) { a = a - b; printf("%d", a); } else ; if (a > b) { a = a - b; printf("%d", a); }

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

View Full Document
16 b b - a a > b true false Write b // ugly if (a > b) ; else { b = b - a; printf("%d", a); } // recommended if (a <= b) { b = b - a; printf("%d", a); }
17 Computer Science: A Structured Programming Approach Using C FIGURE 5-10 Complemented if...else Statements

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

Solutions_Ch05_2_if_else - Chapter 5 Chapter...

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

View Full Document
Ask a homework question - tutors are online