Question: his is a loop nesting exercise. Use two loops, including at least one for loop, to write a C++ program that prints out an upside

his is a loop nesting exercise. Use two loops, including at least one for loop, to write a C++ program that prints out an upside down triangle of stars to the screen.

Write a program from scratch

  • The user will enter the number of stars in the first line, then nested loops will print the triangle of stars. For example:
    How many stars on the first line? 5 ***** **** *** ** *
    or:
    How many stars on the first line? 2 ** *

Tips:

How many stars on the first line? 5 5 4 3 2 1
  • try starting with a counting for loop that counts down from the number the user entered to 1 like this:
  • then add an inner loop that can print that many stars on one line.
  • each loop will have its own counting variable - make sure it has a unique name

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!