Make sure that the user enters a number between 1 and 20, otherwise print an error message and prompt for another number. Exit the program if the user enters 0. For example, if the user enters the number 5, the output would be: ** *** **** C++ programming ***** **** *** ** Use 3 nested loops; 1. the outside loop should prompt for the size of the triangle, then print the triangle for that size and loop back for another triangle's size. (If the user enters O, then exit the program). 2. the middle loop should print each row in a triangle, one row per each iteration. 3. the inside loop should print the asterisks in each row, one iteration per asterisk. Test your program with several different sized triangles. Once you're satisfied that it works, run your program to capture the output of your program when using sizes 4, 5, 8, and 0 (the sentinel). Submit program file(s) and print screens or snips showing the output.
Types of Loop
Loops are the elements of programming in which a part of code is repeated a particular number of times. Loop executes the series of statements many times till the conditional statement becomes false.
Loops
Any task which is repeated more than one time is called a loop. Basically, loops can be divided into three types as while, do-while and for loop. There are so many programming languages like C, C++, JAVA, PYTHON, and many more where looping statements can be used for repetitive execution.
While Loop
Loop is a feature in the programming language. It helps us to execute a set of instructions regularly. The block of code executes until some conditions provided within that Loop are true.
Step by step
Solved in 3 steps with 2 images