The mysterious program is given as: 1 int f(int x, int y) t 2 intr1 3 while (y > 1) 4 if (y % 2-1){ 9 10 return r X 1.
In order to solve this program for x and y, we need to plug in x and y values.
1. For x = 2 and y = 3, f(x,y) will be:
f(2,3) = 22. For x = 1 and y = 7, f(x,y) will be:
f(1,7) = 13. For x = 3 and y = 2, f(x,y) will be:
f(3,2) = 31
Plugging the values into the given program, the program outputs for x and y is 2, 1 and 3, respectively.
The program works as follows:
The function f takes in two integer parameters x and y.
Int r is initialized to 1 and while the value of y is greater than 1:
If the value of y is odd, multiply r by x.If the value of y is even, square the value of x and divide the value of y by 2.
The final value of r is returned.
Learn more about program code at:
https://brainly.com/question/28340916
#SPJ11
Given the code:1 int f(int x, int y) t2 intr13 while (y > 1)4 if (y % 2-1){9 10 return r XWe are to determine the values of f(2,3), f(1,7), and f(3,2) as well as the output of the program given x and y.
As can be seen from the code, the program is defined recursively, that is it calls itself. So let's start by working out f(2,3) which will be the base case upon which we can then build f(1,7) and f(3,2)f(2, 3) = 2 * f(2, 2) = 2 * 4 = 8 where f(2, 2) = 4f(1, 7) = f(2, 6) = 2 * f(1, 5) = 2 * 62 = 12where f(1, 5) = f(2, 4) = 2 * f(1, 3) = 2 * 10 = 20where f(1, 3) = f(2, 2) = 4where f(3, 2) = 3 * f(1, 1) = 3 * 1 = 3 where f(1, 1) = f(1, 0) = 1From the above calculation, the program will output the value of r X which in this case is 8, 12, 3 for f(2, 3), f(1,7), and f(3,2) respectively.
To know more about values visit:
https://brainly.com/question/30145972
#SPJ11