Chapter 8: More on the Repetition Structure

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 4: Control Structures I (Selection)
Chapter 4 - Control Statements
CS 101 Introductory Programming - Lecture 7: Loops In C & Good Coding Practices Presenter: Ankur Chattopadhyay.
Chapter 6: The Repetition Structure
Programming with Microsoft Visual Basic 2008 Fourth Edition
Programming with Microsoft Visual Basic th Edition
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Programming Logic and Design Eighth Edition
CHAPTER 5: Repetition Control Structure. Objectives  To develop algorithms that use DOWHILE and REPEAT.. UNTIL structures  Introduce a pseudocode for.
LOOP / REPETITION while loop. for loop do/while loop We assume that loops are not meant to be infinite. That is, there should always be a way out of the.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
An Introduction to Programming with C++ Fifth Edition
An Introduction to Programming with C++ Fifth Edition Chapter 8 More on the Repetition Structure.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
Chapter 5: Repetition Statements. In this chapter, you will learn about: Basic loop structures while loops Interactive while loops for loops Loop programming.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Seven More on the Repetition Structure.
Chapter 4: Making Decisions. Understanding Logic-Planning Tools and Decision Making Pseudocode – A tool that helps programmers plan a program’s logic.
CPS120 Introduction to Computer Science Iteration (Looping)
Programming Logic and Design Fifth Edition, Comprehensive
Programming Logic and Design Sixth Edition Chapter 5 Looping.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 6 Looping.
Chapter 6: The Repetition Structure
C++ for Engineers and Scientists, Third Edition1 Objectives In this chapter, you will learn about: Basic loop structures while loops Interactive while.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
Computer Programming TCP1224 Chapter 8 More On Repetition Structure.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
CPS120 Introduction to Computer Science Iteration (Looping)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Looping.
1 For Loops l From Chapter 9 l A shorthand way of coding count loops.
Chapter 13 Do It, Then Ask Permission (Posttest Loops) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 14 Do It, Then Ask Permission.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Chapter 6: Looping. Objectives Learn about the loop structure Create while loops Use shortcut arithmetic operators Create for loops Create do…while loops.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Repetition Statements b Repetition statements allow us to execute a statement multiple times repetitively b They are often simply referred to as loops.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Chapter 5: Looping. Using the while Loop Loop – A structure that allows repeated execution of a block of statements Loop body – A block of statements.
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure.
Chapter 8: More on the Repetition Structure
More on the Selection Structure
Exam 2 Review.
Chapter 4 Repetition Statements (loops)
REPETITION CONTROL STRUCTURE
Chapter 3: Decisions and Loops
Programming Logic and Design Fourth Edition, Comprehensive
Chapter 5: Repetition Structures
Chapter 5: Looping Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Learning About the Loop Structure (continued)
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Chapter 5 Repetition.
Making Decisions in a Program
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Objectives After studying this chapter, you should be able to:
Three Special Structures – Case, Do While, and Do Until
Microsoft Visual Basic 2005: Reloaded Second Edition
Flow of Control.
PROGRAM FLOWCHART Iteration Statements.
Chapter 5: The Selection Structure
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Presentation transcript:

Chapter 8: More on the Repetition Structure Introduction to Programming with C++ Fourth Edition

Objectives Show the posttest repetition structure in pseudocode and in a flowchart Code a posttest loop using the C++ do while statement Nest repetition structures Introduction to Programming with C++, Fourth Edition

Posttest Loops Condition is evaluated with each repetition, or iteration, of the loop Evaluation occurs after the instructions within the loop are processed Introduction to Programming with C++, Fourth Edition

Posttest Loops (continued) Introduction to Programming with C++, Fourth Edition

Coding the Posttest Loop In the do while statement, the programmer must supply the loop condition to be evaluated Loop condition: Must be a Boolean expression (true or false) Can contain variables, constants, functions, methods, arithmetic operators, comparison operators, and logical operators Introduction to Programming with C++, Fourth Edition

Coding the Posttest Loop (continued) Programmer must also supply statements to be processed when the loop condition evaluates to true If more than one statement needs to be processed, they must be entered as a statement block Introduction to Programming with C++, Fourth Edition

Syntax of the C++ do while Statement Introduction to Programming with C++, Fourth Edition

Nested Repetition Structures Inner loop - placed entirely within another loop, called the outer loop Introduction to Programming with C++, Fourth Edition

Nested Loops Used by a Clock Introduction to Programming with C++, Fourth Edition

Summary Posttest repetition structure evaluates a condition after the loop body Use the do while statement to code a posttest loop You can also use nested repetition structures Make sure the outer loop completely contains the inner loop Introduction to Programming with C++, Fourth Edition