Nested Counting Loops 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.
The user will enter the number of stars in the first line. For example:
      How many stars on the first line? 5

      *****
      ****
      ***
      **
      *

Tip: this is a loop nesting exercise. Try starting with a counting for loop that counts down from the number the user entered to 1 like this:

      How many stars on the first line? 5
      5
      4
      3
      2
      1

then add an inner loop that can print that many stars on one line.


This page last modified:
Friday, 01-Jun-2018 18:02:08 CST
Accessed     times.

Copyright: Department of Computer Science, University of Regina.