You are on page 1of 22

Problem Solving with Loops

Chapter 7

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Objectives
1. Develop problems using the loop logic structure in conjunction with the decision and sequential logic structures. 2. Use the seven problem-solving tools when developing a solution using the loop logic structure. 3. Use counters and accumulators in a problem solution.

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Objectives
4. Use nested loop instructions to develop a problem solution. 5. Distinguish the different uses of three types of loop logic structures. 6. Use recursion in a simple problem.

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.1 Flowchart Diagram of While/WhileEnd

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.2 Decision Equivalent to While/WhileEnd

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.3 Average Age of a ClassWhile/WhileEnd

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.4 Flowchart Diagram of Repeat/Until

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.5 Decision Equivalent to Repeat/Until

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.6 Average Age of a ClassRepeat/Until

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.7 Flowchart of Automatic-Counter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.8 Decision Equivalents to Automatic-Counter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.9a While/WhileEnd Loop Equivalent of the Automatic-Counter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.9b Repeat/Until Loop Equivalent of the AutomaticCounter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.10 Algorithm for a Problem Using an Automatic-Counter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.10 Flowchart for a Problem Using an AutomaticCounter Loop

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.11 Nested Loops

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Figure 7.11 Nested Loops

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Table 7.1 Algorithm Instructions and Flowchart Symbols

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Table 7.1 Algorithm Instructions and Flowchart Symbols

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Table 7.1 Algorithm Instructions and Flowchart Symbols

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Table 7.1 Algorithm Instructions and Flowchart Symbols

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

Table 7.1 Algorithm Instructions and Flowchart Symbols

Sprankle/Hubbard Problem Solving and Programming Concepts, 8e

Copyright 2009 by Pearson Education, Inc. Upper Saddle River, New Jersey 07458 All rights reserved.

You might also like