The assignment is to implement a recursive function that print “*” to form a tri
ID: 3634768 • Letter: T
Question
The assignment is to implement a recursive function that print “*” to form a triangular pattern. The recursive function you are about to implement has two input parameters m and n. The two input parameters should meet the criteria 2× m = 4 × n. The recursive function should print a pattern of 2((4n-2m)/2+1)=2(2n-m+1) lines to the standard output. The first line contains 2*m asterisks, the next line contains 2*(m+1) asterisks, and so on up to a line with 4*n asterisks.Then the pattern is repeatedbackwards, going n back down to 2*m.
Additional condition,
- Your program should check the criteria (2 × m = 4 × n) for the input parameters. If the input parameters do not meet the criteria, your program should print the warning message.
- Your program should print how many lines are going to be printed. If we name the recursive function as triangle(..), the example out will be as shown below.
Example output for triangle(3, 4)
A pattern of 12 lines will be printed as:
******
********
**********
************
**************
****************
****************
************
**********
********
******
Explanation / Answer
#include using namespace std; void triangle(int m, int n) { if(2*m==4*n) { for(int i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.