Write a recursive function to generate a pattern


Discuss the below:

Q(1) Write a recursive function to generate a pattern such as the following pattern:

*
**
***
****
****
***
**
*

The program should prompt the user to enter the number of lines in the pattern. Enter 4 should generate the above pattern.

Q(2) Write a recursive function to generate a patter such as the following pattern:

*
* *
* * *
* * * *
* * *
* *
*

The program should prompt the user to enter the number of lines in the pattern. Enter 4 should generate the above pattern.

Q(3) A palindrome is a string that reads the same both forward and backward. Write a program that uses a recursive function to check whether a string is a palindrom or not. Your program must contain a value returning recursive function that return true if the string is a palindrome and false otherwise. Do not use any global variables; use the appropriate parameters.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Write a recursive function to generate a pattern
Reference No:- TGS01936948

Now Priced at $25 (50% Discount)

Recommended (96%)

Rated (4.8/5)