tifference is when the condition is checked. The while loop checks the condition before th starts or after the loop ends. A do/while loop will check the condition at the end of the loo letermine if the loop should be repeated. A do'while loop will run at least once whereas a nay be skipped entirely. while ( ) do I/ Repeated code goes here I/ Repeated code goes here 1: while ( );

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 27PE
icon
Related questions
Question
Problem Description:
A while loop and do/while loop will repeat code while the condition is true. The basic
difference is when the condition is checked. The while loop checks the condition before the loop
starts or after the loop ends. A do/while loop will check the condition at the end of the loop to
determine if the loop should be repeated. A do/while loop will run at least once whereas a while
may be skipped entirely.
while (<Condition> )
do
I/ Repeated code goes here
I/ Repeated code goes here
while ( <Condition>);
Checkpoint 1: Use a while loop to display the numbers 1 through 10. You must initialize your
loop counter before the loop and increment the loop counter inside the loop.
Checkpoint 2: Use a while to ask the user for a list of numbers. It is not known how many
numbers the user will enter, but the last number will be -1. After all numbers have been entered,
state how many numbers were put in.
Checkpoint 3: Use a do/while loop to display the numbers I through 10. You must initialize
your loop counter before the loop and increment the loop counter inside the loop.
Checkpoint 4: Use a do/while loop to make a password checker. You should ask the user for a
password (either a string or a number). If they enter the correct password let them into the
system, otherwise state it is an incorrect password and ask again. Set your own password.
Checkpoint 5: Use a while or do/while loop to get input from the user. The input will be an
integer, but make sure they enter a number between 128 and 256. If they do not enter a number
in that range, ask them to enter another number.
Checkpoint 6: Write a loop to display the numbers 1 through 10. Use continue to skip the
output for 4.
Checkpoint 7: Write a loop to display the numbers I through 10. Use break to stop the loop at
number 8.
Transcribed Image Text:Problem Description: A while loop and do/while loop will repeat code while the condition is true. The basic difference is when the condition is checked. The while loop checks the condition before the loop starts or after the loop ends. A do/while loop will check the condition at the end of the loop to determine if the loop should be repeated. A do/while loop will run at least once whereas a while may be skipped entirely. while (<Condition> ) do I/ Repeated code goes here I/ Repeated code goes here while ( <Condition>); Checkpoint 1: Use a while loop to display the numbers 1 through 10. You must initialize your loop counter before the loop and increment the loop counter inside the loop. Checkpoint 2: Use a while to ask the user for a list of numbers. It is not known how many numbers the user will enter, but the last number will be -1. After all numbers have been entered, state how many numbers were put in. Checkpoint 3: Use a do/while loop to display the numbers I through 10. You must initialize your loop counter before the loop and increment the loop counter inside the loop. Checkpoint 4: Use a do/while loop to make a password checker. You should ask the user for a password (either a string or a number). If they enter the correct password let them into the system, otherwise state it is an incorrect password and ask again. Set your own password. Checkpoint 5: Use a while or do/while loop to get input from the user. The input will be an integer, but make sure they enter a number between 128 and 256. If they do not enter a number in that range, ask them to enter another number. Checkpoint 6: Write a loop to display the numbers 1 through 10. Use continue to skip the output for 4. Checkpoint 7: Write a loop to display the numbers I through 10. Use break to stop the loop at number 8.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT