Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ 1. Implement a recursive method fibo that takes an integer num as a pa

ID: 3715877 • Letter: U

Question

Using C++

1. Implement a recursive method fibo that takes an integer num as a parameter and returns the nth
Fibonacci number.
2. Implement a recursive method printDigits that takes an integer num as a parameter and prints its
digits in reverse order, one digit per line.
3. Implement a recursive method mult that takes two integer parameters, x and y and returns their
product. (x*y = x*(y-1)+y. You should know not all computers provide 'product' as an operator. Some computers can only do two operations, plus and minus)
4. Write a program that tests the three methods above.

Explanation / Answer

As per Chegg policy, I am answering only first question:

#include <iostream>
using namespace std;
int fibo(int n);

int main()
{
int n;
cout<<"Enter the number: ";
cin>>n;
cout<<"nth number: "<<fibo(n)<<endl;
return 0;
}

int fibo(int n)
{
if(n==0 || n==1)
return 1;
else
return fibo(n-1)+fibo(n-2);
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote