Question: PROBLEM 2 : ( 2 5 points ) You will write a recursive function in C to print the pattern that is shown in the
PROBLEM : points
You will write a recursive function in C to print the pattern that is shown in the examples below.
You will also write a main program to test your function. Examples are given of the output
on your screen for two values of number of rows. Your program must work for all values of
number of rows and While verifying your value of the number of rows you may need to print any one of the following error messages or prompts.
Enter the number of rows:ERROR: The number of rows is out of range.
ERROR: Too many tries attempting to read the number of rows for the pattern.
HINT: the numbers in each row are determined using the same pattern, for example for
the longest row in the second example:
Second number first number
Third number second number
Fourth number Third number
Fifth number fourth number
Sixth number fifth number
Seventh number sixth number
If you wish you can write an iterative function to print one line of one of these patterns.
The line printed will contain an odd number of integers following the pattern given in the
hint above. You may also elect to include the iterative code to print the single line of the
pattern within your recursive function to print the entire pattern.
You will write a recursive function to print the entire pattern line by line. Recursion is with
respect to the lines of the pattern not numbers in each line of the pattern.
When you look at the examples you will see that the pattern always has an odd number of
lines. If you ask for an even number of lines, Neven, the pattern will be the same as if you
asked for the pattern for Neven lines.
You will write a main program. The main program will read the number of rows. You may
assume the user enters an integer. If the integer entered is out of range reprompt, reread
and retest the value supplied. You should prompt a maximum of times, terminating your
program if no valid value of the number of rows is read in tries.
You will call your recursive function to print the pattern
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
