ssume the availability of a function named printStars that can be passed a parameter containing a non-negative integer value. The function prints out the given number of asterisks. Write a function named printTriangle that receives a parameter that holds a non-negative integer value and prints a triangle of asterisks as follows: first a line of n asterisks, followed by a line of n-1 askterisks, and then a line of n-2 asterisks, and so on. For example, if the function received 5, it would print: ***** **** *** **
Assume the availability of a function named printStars that can be passed a parameter containing a non-negative integer value. The function prints out the given number of asterisks.
Write a function named printTriangle that receives a parameter that holds a non-negative integer value and prints a triangle of asterisks as follows: first a line of n asterisks, followed by a line of n-1 askterisks, and then a line of n-2 asterisks, and so on.
For example, if the function received 5, it would print:
*****
****
***
**
*
The function must not use a loop of any kind (for, while, do-while) to accomplish its job. The function should invoke printStars to accom;lish the task of printing a single line.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images