Recursive function

Consider the following recursive function:

int test(int x, int y)

 

    if (abs(x – y) <=>

        return x + y;

else if (x > y)

        return test(x – 1, y + 1);

    else if (y > x)

        return test(x + 1, y – 1);

 

 What is the output of the following statements? (4, 6)

a. cout < test(8,=”” 2)=””>< endl;=””>

b. cout < test(5,=”” 16)=””>< endl;=””>

c. cout < test(-25,=”” 2)=””>< endl;=””>

d. cout < test(8,=”” -6)=””>< endl;=””>

e. cout < test(-20,=”” -36)=””><>

Write a recursive algorithm to multiply two positive integers m and n using repeated addition. Specify the base case and the recursive case. (2, 3, 4, 6)

WhatsApp
Hello! Need help with your assignments?

For faster services, inquiry about  new assignments submission or  follow ups on your assignments please text us/call us on +1 (251) 265-5102

🛡️ Worried About Plagiarism? Run a Free Turnitin Check Today!
Get peace of mind with a 100% AI-Free Report and expert editing assistance.

X