Solutions_Ch05_2_if_else

Solutions_Ch05_2_if_else - Chapter 5 Chapter...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
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:
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Computer Science: A Structured Programming Approach Using C FIGURE 5-6 Two-way Decision Logic
Background image of page 4
5 Computer Science: A Structured Programming Approach Using C FIGURE 5-7 if. ..else Logic Flow
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Computer Science: A Structured Programming Approach Using C b b - a a > b a a - b true false
Background image of page 6
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
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Computer Science: A Structured Programming Approach Using C Table 5-2 Syntactical Rules for if…else Statements
Background image of page 8
9 Computer Science: A Structured Programming Approach Using C FIGURE 5-8 A Simple if. ..else Statement
Background image of page 9

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

View Full DocumentRight Arrow Icon
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); }
Background image of page 10
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); }
Background image of page 11

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

View Full DocumentRight Arrow Icon
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); }
Background image of page 12
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); }
Background image of page 13

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

View Full DocumentRight Arrow Icon
14 Computer Science: A Structured Programming Approach Using C FIGURE 5-9 Compound Statements in an if. ..else
Background image of page 14
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); }
Background image of page 15

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

View Full DocumentRight Arrow Icon
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); }
Background image of page 16
17 Computer Science: A Structured Programming Approach Using C FIGURE 5-10 Complemented if. ..else Statements
Background image of page 17

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

View Full DocumentRight Arrow Icon
Image of page 18
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/24/2010 for the course CIS 15 taught by Professor Delia during the Summer '10 term at DeAnza College.

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 Right Arrow Icon
Ask a homework question - tutors are online