YCP Logo Lab 28: Recursion

Due: Monday, Dec 1st by 11:59 PM

Getting started

If you have a solution open in Visual Studio, close it (File->Close Solution).

Download CS200_Lab28.zip. Import it into Visual Studio (File->Import...).

Add your code to the source file called Recursion.c.

Your Task

Your task is to implement three functions: factorial, all_odd_digits, and search. The comments in the source file describe how each function should work. The main function contains tests for each of the three functions. You will not need to change any code in the main function.

Implement factorial first, then all_odd_digits, then search.

For each function, implement the function recursively. Do not use a loop in any function!

The body of each function has a comment with some hints on how to approach the recursion.

When you implementing all three functions, the output of the program will look like this:

Checking that 1 == factorial(1) at line 93: YES
Checking that 2 == factorial(2) at line 94: YES
Checking that 6 == factorial(3) at line 95: YES
Checking that 24 == factorial(4) at line 96: YES
Checking that 120 == factorial(5) at line 97: YES
Checking that 720 == factorial(6) at line 98: YES
Checking that all_odd_digits(131) is true at line 100: YES
Checking that all_odd_digits(121) is false at line 101: YES
Checking that all_odd_digits(90125) is false at line 102: YES
Checking that all_odd_digits(42) is false at line 103: YES
Checking that all_odd_digits(1357195) is true at line 104: YES
Checking that 0 == search(sequence, 0, 10, 92) at line 106: YES
Checking that 2 == search(sequence, 0, 10, 72) at line 107: YES
Checking that 8 == search(sequence, 0, 10, 38) at line 108: YES
Checking that 3 == search(sequence, 0, 10, 11) at line 109: YES
Checking that -1 == search(sequence, 0, 10, 42) at line 110: YES
All tests passed!


When you are done, choose Tools->Submit to submit your completed lab to the server. You will need to enter your Marmoset username and password.

If the Tools->Submit option does not work, create a zip file containing the files in your project, and upload it to the submission server as lab28. The server URL is