Question: b) Trace the recursion given by the following code for the data: 7 4 similar to the examples provided by the instructor in class. Do

b) Trace the recursion given by the following code for the data: 7 4

similar to the examples provided by the instructor in class. Do not forget to include the parameters values at each call and the value returned by the called function.

#include using namespace std; int mysteryrecursion(int a, int b) { if ( b==1) { return a; } else { return a + mysteryrecursion(a, b-1); } } int main() { int x = 6; int y = 2; cin >> x >> y; cout << mysteryrecursion(x, y) << endl; return 0; } Trace:

What does the code above accomplish? (If youre not sure try different values until you see a pattern.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!