Questions: 1. A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here to remove the break statement from the program of Fig. 5.13. 2. Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << '*'; (this causes the asterisks to print side by side).  [Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.]

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter5: Looping
Section: Chapter Questions
Problem 7RQ
icon
Related questions
Question

Questions:
1. A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here to remove the break statement from the program of Fig. 5.13.

2. Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << '*'; (this causes the asterisks to print side by side). 

[Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.]

(Drawing Patterns with Nested for Loops) Write a program that uses for statements to
print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << '*'; (this causes the asterisks to print side by side). 

[Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.]

Questions:
1. A criticism of the break and continue statements is that each is unstructured. These
statements can always be replaced by structured statements. Describe in general how
you'd remove any break statement from a loop in a program and replace it with some
structured equivalent. [Hint: The break statement leaves a loop from within the body
ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in
theloop-continuation test a second test that indicates "early exit because of a 'break'
condition."] Use the technique you developed here to remove the break statement from
the program of Fig. 5.13.
2. Write a program that uses for statements to print the following patterns
separately, one below the other. Use for loops to generate the patterns. All
asterisks (*) should be printed by a single statement of the form cout << *; (this
causes the asterisks to print side by side).
[Hint: The last two patterns require that each line begin with an appropriate number of blanks.
Extra credit: Combine your code from the four separate problems into a single program that
prints all four patterns side by side by making clever use of nested for loops.]
(Drawing Patterns with Nested for Loops) Write a program that uses for statements to
print the following patterns separately, one below the other. Use for loops to generate the
patterns. All asterisks (*) should be printed by a single statement of the form cout <« *; (this
causes the asterisks to print side by side).
[Hint: The last two patterns require that each line begin with an appropriate number of blanks.
Extra credit: Combine your code from the four separate problems into a single program that
prints all four patterns side by side by making clever use of nested for loops.)
(b)
(c)
(d)
Transcribed Image Text:Questions: 1. A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you'd remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates "early exit because of a 'break' condition."] Use the technique you developed here to remove the break statement from the program of Fig. 5.13. 2. Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << *; (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.] (Drawing Patterns with Nested for Loops) Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout <« *; (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.) (b) (c) (d)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
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
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