Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a recursive function printTriangle ( ) that takes two integers as parameters and prints a triangle of asterisks based on those parameters. The first
Write a recursive function printTriangle that takes two integers as parameters
and prints a triangle of asterisks based on those parameters. The first integer represents the
maximum number of asterisks to be printed in the last row of the triangle pattern seen in the
examples below. The second integer represents the indentation used for the last line of the
pattern. The first parameter may be zero or negative, in which case nothing should be printed.
You should assume that the second parameter is nonnegative There is no relationship
assumed between the two parameters. You are allowed to use string multiplication eg c n for a
character c and an integer n and concatenation, but no other string functions are allowed. The
following shows several sample runs of the function:File Edit Shell Debug Options Windows Help
printTriangle
t
t
tot
printTriangle
tt
printTriangle
ttt
printTriangle
printTriangle
printTriangle
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started