Write a recursive method that takes as a parameter a nonnegative integer and gen
ID: 3680631 • Letter: W
Question
Write a recursive method that takes as a parameter a nonnegative integer and generates the following pattern of stars. If the nonnegative integer is 4, then the pattern generated is: Write a recursive method String reverse (String text) that reverses a string. For example, reverse ("Hello") returns the string "! olleH". Implement a recursive solution by removing the first character, reversing the remaining text, and combining the two. Write a recursive method power, that takes as parameters two integers x and y such that x is nonzero and returns x^y.Explanation / Answer
13.3)
Output:
13.2)
13.1)
#include "stdio.h"
int main()
{
int num,i,j,k,m,n,o,p;
printf("Please enter a number to print the star formations ");
scanf("%d", &num);
printf(" ");
j=0,i=0,k=0;
for(i=num;i>0;i--)
{
for(j=i;j>0;j--)
{
printf("*");
}
printf(" ");
}
printf(" ");
printf(" ");
j=0,i=0,k=0;
for(i=0;i<num;i++)
{
for(j=0;j<=i;j++)
{
printf("*");
}
printf(" ");
}
return 0;
}
Related 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.