3. Observe the following formulae: fin) = 1 fin) = 3 + f(n-1) fin) = 2 + f(n-1) if n=0 if n is even if n is odd a) Write a direct recursive function based on the formulae above. The function prototype...


3. Observe the following formulae:<br>fin) = 1<br>fin) = 3 + f(n-1)<br>fin) = 2 + f(n-1)<br>if n=0<br>if n is even<br>if n is odd<br>a) Write a direct recursive function based on the formulae above. The function prototype is given<br>as:<br>int f(int n);<br>Note: You don't have to worry about n being less than 0, but beware of 0 being an even<br>number.<br>b) Using mutual recursion and based on the formulae above, complete the function definition<br>for the following function prototypes:<br>int fodd (int n) ;<br>int fEven (int n);<br>c) Write a complete C program to test the direct and mutual recursions that you have written in<br>Parts (a) and (b). Prompt the user for n values.<br>

Extracted text: 3. Observe the following formulae: fin) = 1 fin) = 3 + f(n-1) fin) = 2 + f(n-1) if n=0 if n is even if n is odd a) Write a direct recursive function based on the formulae above. The function prototype is given as: int f(int n); Note: You don't have to worry about n being less than 0, but beware of 0 being an even number. b) Using mutual recursion and based on the formulae above, complete the function definition for the following function prototypes: int fodd (int n) ; int fEven (int n); c) Write a complete C program to test the direct and mutual recursions that you have written in Parts (a) and (b). Prompt the user for n values.

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here