Write a C program that uses a recursive function and random sequence generator in an attempt to
predict users' age (15-80 years old). The designed logic in your program must use a recursive
function to produce a similar behavior like the one shown below:
Let me try to guess your age!
Is your age 30 (Y/N): n
Is your age lower or higher than 30
(L/H) : h
Is your age 57 (Y/N): no
Is your age lower or higher than 57 (L/H): lower
Is your age 46 (Y/N): what?
INVALID CHOICE, TRY AGAIN
Is your age 46 (Y/N): N
Is your age lower or higher than 46 (L/H): Never
INVALID CHOICE, TRY AGAIN
Is your age lower or higher than 46 (L/H): L
Is your age 43 (Y/N): N
Is your age lower or higher than 43 (L/H): higher
Is your age 44 (Y/N): yes
Fantastic! It only took me 5 tries to guess your age%
When designing the program, make sure:
1- The system flexible to accept both lower case and upper case character choice options
(i.e., H and h), and also words in which the first character is one of the accepted
characters (i.e., Lower and lower).
2- The system displays an error message (INVALID CHOICE, TRY AGAIN) If any other
inputs are provided by user (input validation).
3- The code reports the number of tries your system made to get the correct answer (This is
a recursive mechanism, which means multiple tries).
As indicated in the class, recursion is used to solve complex problems by dividing it into small
problems. The smallest sub problem to solve is:
➤ Guessing an age between the minimum and maximum possible age for the user
Checking if that age is less than or greater than the user's actual age
Tips:
1. To get a random number (guess the age), you can use this formula
int newAge (int) ((double) rand() / RAND_MAX* (max
min)) + min);
2. Don't forget to seed the random number generator at the start of your code (please see
lecture 06 slides on canvas)
If the guess is more, the algorithm has a new maximum possible value; if the guess is
less, the algorithm has a new minimum possible value
Grading Rubric:



Able to call a function recursively (50 pts)
Able to correctly perform all input validations (15 pts)
Able to correctly to use recursion to ultimately guess user's age (25 pts)
Able to correctly reports the number of tries (10 pts)