Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a recursive function with two unsigned int parameters, m and n. The precon

ID: 3720779 • Letter: W

Question

Write a recursive function with two unsigned int parameters, m and n. The precondition requires 0 <= m and m <= n. The function prints a line of m asterisks, then a line of m+1 asterisks, and so on up to a line of n asterisks. Then the same pattern is repeated backward: a line of n asterisks, then n-1, and so on down to m. The only loop allowed in your implementation is a loop to print a line of m asterisks. You may have two copies of this loop in different places of the implementation. (10 points)

Explanation / Answer

Hi Friend, You have not mentioned about required programming language.

So i have implemented in C.

#include<stdio.h>
int asterisk(unsigned int, unsigned int);
int main()
{
unsigned int m,n;
asterisk(m,n);
return 0;
}
int asterisk(unsigned int m, unsigned int n)
{
if((0<=m)&&(m<=n))
{
for(i=0;i<m;i++)
printf("*");

printf(" ");
asterisk(m+1,n);
asterisk(m-1,n);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote