


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Write a program that asks the user to enter the size of atriangle to print out (an integer from 1 to 50), then printthe triangle by printing a series of lines consisting ofasterisks. The first line will have one asterisk, the nexttwo, and so on, with each line having one more asteriskthan the previous line, up to the number entered by theuser. On the next line print one less asterisk andcontinue by decreasing the number of asterisks by 1 foreach successive line until only one asterisk is printed. Hint
: Use nested
for
loops; the outside loop controls the
number of lines to print, and the inside loop controls thenumber of asterisks to print on a line. For example, if theuser enters
, the output would be (next page)
-^
height
height
is
, then print the
following.