Submit Search
Upload
Chapter 8 - More on the Repetition Structure
•
Download as PPT, PDF
•
1 like
•
958 views
M
mshellman
Follow
More on the Repetition Structure
Read less
Read more
Education
Report
Share
Report
Share
1 of 39
Download now
Recommended
Chapter 5 - The Selection Structure
Chapter 5 - The Selection Structure
mshellman
Chapter 7 - The Repetition Structure
Chapter 7 - The Repetition Structure
mshellman
Chapter 3 - Variables and Constants
Chapter 3 - Variables and Constants
mshellman
Chapter 4 - Completing the Problem-Solving Process
Chapter 4 - Completing the Problem-Solving Process
mshellman
Chapter 9 Value-Returning Functions
Chapter 9 Value-Returning Functions
mshellman
Chapter 2 - Beginning the Problem-Solving Process
Chapter 2 - Beginning the Problem-Solving Process
mshellman
Loops Basics
Loops Basics
Mushiii
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
SamuelAnsong6
Recommended
Chapter 5 - The Selection Structure
Chapter 5 - The Selection Structure
mshellman
Chapter 7 - The Repetition Structure
Chapter 7 - The Repetition Structure
mshellman
Chapter 3 - Variables and Constants
Chapter 3 - Variables and Constants
mshellman
Chapter 4 - Completing the Problem-Solving Process
Chapter 4 - Completing the Problem-Solving Process
mshellman
Chapter 9 Value-Returning Functions
Chapter 9 Value-Returning Functions
mshellman
Chapter 2 - Beginning the Problem-Solving Process
Chapter 2 - Beginning the Problem-Solving Process
mshellman
Loops Basics
Loops Basics
Mushiii
Object Oriented Programming (OOP) Introduction
Object Oriented Programming (OOP) Introduction
SamuelAnsong6
Chapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection Structure
mshellman
History of c++
History of c++
Ihsan Wassan
While loop,Do While loop ,for loop
While loop,Do While loop ,for loop
MuhammadWaseem305
Interfaces in java
Interfaces in java
Abishek Purushothaman
Java applets
Java applets
Srinath Dhayalamoorthy
Repetition Structure
Repetition Structure
PRN USM
java Features
java Features
Jadavsejal
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Toshiaki Maki
Control statements in java programmng
Control statements in java programmng
Savitribai Phule Pune University
Method overloading
Method overloading
Lovely Professional University
Chapter 9 Abstract Class
Chapter 9 Abstract Class
OUM SAOKOSAL
C/C++とWebAssemblyを利用したライブラリ開発
C/C++とWebAssemblyを利用したライブラリ開発
祐司 伊藤
Object+oriented+programming+in+java
Object+oriented+programming+in+java
Ye Win
Task parallel library presentation
Task parallel library presentation
ahmed sayed
golang.tokyo #6 (in Japanese)
golang.tokyo #6 (in Japanese)
Yuichi Murata
Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...
Warren0989
Java programming course for beginners
Java programming course for beginners
Eduonix Learning Solutions
OOPs Concepts - Android Programming
OOPs Concepts - Android Programming
Purvik Rana
Basic for Loop in C
Basic for Loop in C
Rohit Soni
C++
C++
VishalMishra313
Lesson 8 more on repitition structure
Lesson 8 more on repitition structure
MLG College of Learning, Inc
Lesson 7.1 repitition structure
Lesson 7.1 repitition structure
MLG College of Learning, Inc
More Related Content
What's hot
Chapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection Structure
mshellman
History of c++
History of c++
Ihsan Wassan
While loop,Do While loop ,for loop
While loop,Do While loop ,for loop
MuhammadWaseem305
Interfaces in java
Interfaces in java
Abishek Purushothaman
Java applets
Java applets
Srinath Dhayalamoorthy
Repetition Structure
Repetition Structure
PRN USM
java Features
java Features
Jadavsejal
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Toshiaki Maki
Control statements in java programmng
Control statements in java programmng
Savitribai Phule Pune University
Method overloading
Method overloading
Lovely Professional University
Chapter 9 Abstract Class
Chapter 9 Abstract Class
OUM SAOKOSAL
C/C++とWebAssemblyを利用したライブラリ開発
C/C++とWebAssemblyを利用したライブラリ開発
祐司 伊藤
Object+oriented+programming+in+java
Object+oriented+programming+in+java
Ye Win
Task parallel library presentation
Task parallel library presentation
ahmed sayed
golang.tokyo #6 (in Japanese)
golang.tokyo #6 (in Japanese)
Yuichi Murata
Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...
Warren0989
Java programming course for beginners
Java programming course for beginners
Eduonix Learning Solutions
OOPs Concepts - Android Programming
OOPs Concepts - Android Programming
Purvik Rana
Basic for Loop in C
Basic for Loop in C
Rohit Soni
C++
C++
VishalMishra313
What's hot
(20)
Chapter 6 - More on the Selection Structure
Chapter 6 - More on the Selection Structure
History of c++
History of c++
While loop,Do While loop ,for loop
While loop,Do While loop ,for loop
Interfaces in java
Interfaces in java
Java applets
Java applets
Repetition Structure
Repetition Structure
java Features
java Features
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Control statements in java programmng
Control statements in java programmng
Method overloading
Method overloading
Chapter 9 Abstract Class
Chapter 9 Abstract Class
C/C++とWebAssemblyを利用したライブラリ開発
C/C++とWebAssemblyを利用したライブラリ開発
Object+oriented+programming+in+java
Object+oriented+programming+in+java
Task parallel library presentation
Task parallel library presentation
golang.tokyo #6 (in Japanese)
golang.tokyo #6 (in Japanese)
Solutions manual for c++ programming from problem analysis to program design ...
Solutions manual for c++ programming from problem analysis to program design ...
Java programming course for beginners
Java programming course for beginners
OOPs Concepts - Android Programming
OOPs Concepts - Android Programming
Basic for Loop in C
Basic for Loop in C
C++
C++
Similar to Chapter 8 - More on the Repetition Structure
Lesson 8 more on repitition structure
Lesson 8 more on repitition structure
MLG College of Learning, Inc
Lesson 7.1 repitition structure
Lesson 7.1 repitition structure
MLG College of Learning, Inc
Lesson 6.2 logic error
Lesson 6.2 logic error
MLG College of Learning, Inc
Lesson 9.2 guessing the game program
Lesson 9.2 guessing the game program
MLG College of Learning, Inc
Lesson 7.2 using counters and accumulators
Lesson 7.2 using counters and accumulators
MLG College of Learning, Inc
Lesson 9.1 value returning
Lesson 9.1 value returning
MLG College of Learning, Inc
Lesson 6.1 more on selection structure
Lesson 6.1 more on selection structure
MLG College of Learning, Inc
Lecture 1 programming fundamentals (PF)
Lecture 1 programming fundamentals (PF)
Kamran Zafar
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programming
mshellman
Lesson 1 introduction to programming
Lesson 1 introduction to programming
MLG College of Learning, Inc
Sql9e ppt ch08
Sql9e ppt ch08
Dr. Ahmed Al Zaidy
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
keturahhazelhurst
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
robertad6
Omni channel network design
Omni channel network design
faiza20202880
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
at315244
Mechatronics engineer
Mechatronics engineer
Samuel Narcisse
Cwin16 tls-s2-implementing a dev ops pipeline
Cwin16 tls-s2-implementing a dev ops pipeline
Capgemini
Questions Log: Transitioning to Cognos Workspace Advanced
Questions Log: Transitioning to Cognos Workspace Advanced
Senturus
Continuous Integration Testing Techniques to Improve Chef Cookbook Quality
Continuous Integration Testing Techniques to Improve Chef Cookbook Quality
Josiah Renaudin
Sql9e ppt ch03
Sql9e ppt ch03
Dr. Ahmed Al Zaidy
Similar to Chapter 8 - More on the Repetition Structure
(20)
Lesson 8 more on repitition structure
Lesson 8 more on repitition structure
Lesson 7.1 repitition structure
Lesson 7.1 repitition structure
Lesson 6.2 logic error
Lesson 6.2 logic error
Lesson 9.2 guessing the game program
Lesson 9.2 guessing the game program
Lesson 7.2 using counters and accumulators
Lesson 7.2 using counters and accumulators
Lesson 9.1 value returning
Lesson 9.1 value returning
Lesson 6.1 more on selection structure
Lesson 6.1 more on selection structure
Lecture 1 programming fundamentals (PF)
Lecture 1 programming fundamentals (PF)
Chapter 1 - An Introduction to Programming
Chapter 1 - An Introduction to Programming
Lesson 1 introduction to programming
Lesson 1 introduction to programming
Sql9e ppt ch08
Sql9e ppt ch08
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
CHAPTER 4Distribution and Omni-Channel Network DesignSu.docx
Omni channel network design
Omni channel network design
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
DC16_Ch09_Operating Systems Managing, Coordinating, and Monitoring Resources....
Mechatronics engineer
Mechatronics engineer
Cwin16 tls-s2-implementing a dev ops pipeline
Cwin16 tls-s2-implementing a dev ops pipeline
Questions Log: Transitioning to Cognos Workspace Advanced
Questions Log: Transitioning to Cognos Workspace Advanced
Continuous Integration Testing Techniques to Improve Chef Cookbook Quality
Continuous Integration Testing Techniques to Improve Chef Cookbook Quality
Sql9e ppt ch03
Sql9e ppt ch03
Recently uploaded
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
TechSoup
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
Chameera Dedduwage
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
pboyjonauth
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
KarinaGenton
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
9953056974 Low Rate Call Girls In Saket, Delhi NCR
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
Marc Dusseiller Dusjagr
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
Sayali Powar
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Celine George
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
SafetyChain Software
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
RKavithamani
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
iammrhaywood
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
David Douglas School District
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
RoyAbrique
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
EduSkills OECD
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Steve Thomason
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
ChitralekhaTherkar
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
chloefrazer622
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
InMediaRes1
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Sarwono Sutikno, Dr.Eng.,CISA,CISSP,CISM,CSX-F
Recently uploaded
(20)
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Chapter 8 - More on the Repetition Structure
1.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Introduction to Programming in C++ Eighth Edition Chapter 8: More on the Repetition Structure
2.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Include a posttest loop in pseudocode • Include a posttest loop in a flowchart • Code a posttest loop using the C++ do while statement • Nest repetition structures Objectives An Introduction to Programming with C++, Eighth Edition 2
3.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Repetition structures can be either pretest or posttest loops • Pretest loop – condition evaluated before instructions are processed • Posttest loop – condition evaluated after instructions are processed • Posttest loop’s instructions are always processed at least once • Pretest loop’s instructions may never be processed Posttest Loops An Introduction to Programming with C++, Eighth Edition 3
4.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. An Introduction to Programming with C++, Eighth Edition 4 Figure 8-1 Problem specification, illustrations, and solutions containing pretest and posttest loops Posttest Loops (cont’d.)
5.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Posttest Loops (cont’d.) An Introduction to Programming with C++, Eighth Edition 5 Figure 8-2 Selection structure added to Solution 2 from Figure 8-1
6.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Decision symbol in a flowchart (a diamond) representing a repetition structure contains the loop condition • Decision symbol appears at the top of a pretest loop, but at the bottom of a posttest loop Flowcharting a Posttest Loop An Introduction to Programming with C++, Eighth Edition 6
7.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. An Introduction to Programming with C++, Eighth Edition 7 Figure 8-3 Commission Program’s problem specification and flowcharts Flowcharting a Posttest Loop (cont’d.)
8.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. An Introduction to Programming with C++, Eighth Edition 8 Figure 8-3 Commission Program’s problem specification and flowchart Flowcharting a Posttest Loop (cont’d.)
9.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • do while statement is used to code posttest loops in C++ • Syntax: do { one or more statements to be processed one time, and thereafter as long as the condition is true } while (condition); • Some programmers use a comment (such as: //begin loop) to mark beginning of loop The do while Statement An Introduction to Programming with C++, Eighth Edition 9
10.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Programmer must provide loop condition – Must evaluate to a Boolean value – May contain variables, constants, functions, arithmetic operators, comparison operators, and logical operators • Programmer must also provide statements to be executed when condition evaluates to true • Braces are required around statements if there are more than one The do while Statement (cont’d.) An Introduction to Programming with C++, Eighth Edition 10
11.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. An Introduction to Programming with C++, Eighth Edition 11 Figure 8-4 How to use the do while statement The do while Statement (cont’d.)
12.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. An Introduction to Programming with C++, Eighth Edition 12 Figure 8-5 Commission Program containing a posttest loop The do while Statement (cont’d.)
13.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Like selection structures, repetition structures can be nested • You can place one loop (the inner, or nested loop) inside another loop (the outer loop) • Both loops can be pretest loops or posttest loops, or the two loops may be different types • Programmer decides whether a problem requires a nested loop by analyzing the problem specification Nested Repetition Structures An Introduction to Programming with C++, Eighth Edition 13
14.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Nested Repetition Structures (cont’d.) An Introduction to Programming with C++, Eighth Edition 14 Figure 8-6 Problem specification and solution that requires a loop
15.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Nested Repetition Structures (cont’d.) An Introduction to Programming with C++, Eighth Edition 15 Figure 8-7 Modified problem specification and solution that requires a nested loop
16.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Simple program that simulates a clock with minutes and seconds. • The outer loop represents minutes. • The inner loop (nested loop) represents seconds. • To make it easier to desk-check the instructions, the nested loop uses only three seconds per minute and the outer loop stops after two minutes. The Clock Program An Introduction to Programming with C++, Eighth Edition 16
17.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. The Clock Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 17 Figure 8-8 Algorithm, code, and a sample run of the Clock Program
18.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. The Clock Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 18 Figure 8-10 Completed desk-check table and output
19.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Calculate the depreciation of a car over time. • Program uses a counter-controlled loop to display the value of a new car at the end of each of five years, using a 15% annual depreciation rate. The Car Depreciation Program An Introduction to Programming with C++, Eighth Edition 19
20.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Car Depreciation Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 20 Figure 8-11 Beginning of Car Depreciation Program with Problem Specification
21.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Car Depreciation Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 21 Figure 8-11 Remainder of Car Depreciation Program with sample run
22.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Modify the Car Depreciation Program to use different depreciation rates. • This modified program displays the value of a new car at the end of each of five years, using annual depreciation rates of 15%, 20%, and 25%. Car Depreciation Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 22
23.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Car Depreciation Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 23 Figure 8-12 Beginning of the modified Car Depreciation Program with problem specification
24.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Car Depreciation Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 24 Figure 8-12 Remainder of the modified Car Depreciation Program with sample run
25.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Car Depreciation Program (cont’d.) An Introduction to Programming with C++, Eighth Edition 25 Figure 8-13 Flowchart for the modified Car Depreciation Program
26.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • A repetition structure can be either a pretest loop or a posttest loop • In a pretest loop, the loop condition is evaluated before the instructions in the loop are processed • In a posttest loop, the evaluation occurs after the instructions within the loop are processed • Use the do while statement to code a posttest loop in C++ • Use either the while statement or the for statement to code a pretest loop in C++ Summary An Introduction to Programming with C++, Eighth Edition 26
27.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Repetition structures can be nested, which means one loop (called the inner or nested loop) can be placed inside another loop (called the outer loop) • For nested repetition structures to work correctly, the entire inner loop must be contained within the outer loop Summary (cont’d.) An Introduction to Programming with C++, Eighth Edition 27
28.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Study the program below and answer the questions. Lab 8-1: Stop and Analyze An Introduction to Programming with C++, Eighth Edition 28 Figure 8-14 Code for Lab 8-1
29.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create An Introduction to Programming with C++, Eighth Edition 29 Figure 8-15 Problem specification, IPO chart, and desk- check table for the Retirement program
30.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create (cont’d.) An Introduction to Programming with C++, Eighth Edition 30 Figure 8-15 Remainder of the desk-check table for the Retirement program
31.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create (cont’d.) An Introduction to Programming with C++, Eighth Edition 31 Figure 8-16 Beginning of the IPO chart information and C++ instructions for the Retirement program
32.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create (cont’d.) An Introduction to Programming with C++, Eighth Edition 32 Figure 8-16 Remainder of the IPO chart information and C++ instructions for the Retirement program
33.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create (cont’d.) An Introduction to Programming with C++, Eighth Edition 33 Figure 8-17 Desk-check table for the Retirement program
34.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create (cont’d.) An Introduction to Programming with C++, Eighth Edition 34 Figure 8-18 Beginning of the finalized Retirement program
35.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Lab 8-2: Plan and Create (cont’d.) An Introduction to Programming with C++, Eighth Edition 35 Figure 8-18 Remainder of the finalized Retirement program
36.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Modify the program in Lab8-2.cpp. Change the outer for loop to a posttest loop. Save the modified program as Lab8- 3.cpp • Save, run, and test the program. Lab 8-3: Modify An Introduction to Programming with C++, Eighth Edition 36
37.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • The program is this lab should display the pattern of numbers shown in Figure 8-19 below. • Follow the instructions for starting C++ and opening the Lab8-4.cpp file. Put the C++ instructions in the proper order, and then determine the one or more missing instructions. • Test the program appropriately. Lab 8-4: What’s missing? An Introduction to Programming with C++, Eighth Edition 37 Figure 8-19 Sample output for Lab 8-4
38.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Desk-check the code in Figure 8-20 • What will the code display on the computer screen? Lab 8-5: Desk-Check An Introduction to Programming with C++, Eighth Edition 38 Figure 8-20 Code for Lab 8-5
39.
© 2016 Cengage
Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. • Follow the instructions for starting C++ and opening the Lab8-6.cpp file. • The program should display a store’s quarterly sales, but it is not working properly. • Debug the program. Lab 8-6: Debug An Introduction to Programming with C++, Eighth Edition 39
Download now