Mysterious Program Consider this mysterious program. 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. Find the values f(2, 3), f(1,7), f(3,2) and determine what the program output given x and y

Answers

Answer 1

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

Answer 2

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


Related Questions

Other Questions
(Financing Component) On Jan. 1, 20x1, ABC Co. enters into a Contract with a customer to transfer a license for a fixed fee of P100,000 payable as follows: a. 20% upon signing of contract. b. Balance due in 4 equal annual installments starting Dec. 31, 20x1. The discount rate is 12%. ABC incurs direct contract costs of P20,000 in 20x1. ABC transfers the license to the customer on Jan. 3, 20x2. The license provides the customer with the right to use ABC's intellectual property as it exists at grant date. Requirement: Compute for the profits in 20x1 and 20x2 respectively. 1. 2020, Q1 data:Consumption = $13.18 b GDPI = 3.27 bExports = 2.48 b Imports = 3.29 bGovernment expenditure: 3.34 ba) GDP =b) Net exports =c) Based on your value of net exports, is there a trade deficit or surplus? changes that can be made to the hud 1 good faith estimate what is the form of business ownership where you are taxed only at the personal level? What would be the molecular formula for a polymer made from eight glucose (C6H12O6) molecules linked together by dehydration reactions?Answer choices:C48H80O40orC48H82O41 Determine the velocity of a marble (m = 8.66 g) with a wavelength of 3.46 10-33m.a.45.2 m/sb.11.3 m/sc.22.1 m/sd.38.8 m/se.52.9 m/s Always end a bad news message with a positive statement.TRUEFALSE Smartphones: A poll agency reports that 80% of teenagers aged 12-17 own smartphones. A random sample of 250 teenagers is drawn. Round your answers to at least four decimal places as needed. Dart 1 n6 (1) Would it be unusual if less than 75% of the sampled teenagers owned smartphones? It (Choose one) be unusual if less than 75% of the sampled teenagers owned smartphones, since the probability is Below, n is the sample size, p is the population proportion and p is the sample proportion. Use the Central Limit Theorem and the TI-84 calculator to find the probability. Round the answer to at least four decimal places. n=148 p=0.14 PC A marketing dashboard is live view of the people and activities vital to the corporation. Select one: O True O False TRUE/FALSE. State whether each of the following statements is true or false. Justify your answer in each case. (a) NH3 contains no OH- ions, and yet its aqueous solutions are basic mrs. smith wants to be sure she teaches her class how to properly behave in a big city before they go on their own. to teach them how to cross an avenue as a group, she would______. Select an organized criminal group of your choosing. Explain which group you have selected and why you have selected it.Briefly describe the main types and/ or methods of criminal activity of the organized criminal group that you have selected.Examine at least two of the types/ methods of criminal activity that you have selected through the lens of the Organized Crime Convention. In particular, identify a number of Convention provisions that we have examined during the course that are relevant to this criminal activity and explain how they apply to the facts of the organized criminal group you selected. [At least 500 words should focus on this aspect which requires the most discussion and analysis]. The table shows the total revenue of the 50 firms in the candy and confectionery industry. Calculate the four-firm concentration ratio and the HHI. >>> Answer to 2 decimal places. Firm Sugar Mountain Sugar + Spice Simply Candy Fudge Factory Next 16 firms (each) Next 30 firms (each) Industry Total revenue (dollars) 450 325 250 200 50 The four-firm concentration ratio equals The HHI equals 20 2,625 The four-firm concentration ratio indicates that the market is and the Herfindahl-Hirschman Index indicates that the market is (Assume there are no reasons that would make the concentration measures unreliable guides.) A. monopolistic competition; a monopoly B. a monopoly; a monopoly C. monopolistic competition; monopolistic competition D. a monopoly; monopolistic competition E. probably not monopolistic competition; monopolistic competition The National Fire Protection Association has classified firesaccording to three basic types. List them, including a briefdescription of each. HUD E 4 8 10 6 Computers Suppose the economy is currently producing 12 bicycles and 2 computers at Point B. What is the opportunit cost of increasing computer output to 4 units at Point C? 4 bicycles 3 bicycles 5 bicycles zero because unemployed resources are available irrelevant because this decision is inconsistent with consumer preferences Allison missed her shift at the restaurant in order to attend a hockey game. She paid $45 for the and drank $20 worth of beer. Had she worked her shift, Allison would have earned $200. Her opportunity cost of attending the game is: A) $160. B) $150. C) $100. D) $60. E) $0. 200 120 90 290 0 each of the following is a confidence interval for = true average (i.e., population mean) resonance frequency (hz) for all tennis rackets of a certain type: (112.6, 113.4) (112.4, 113.6) 5. A restaurant has large tanks that are cleaned daily. Cleaning includes the use of packaged detergents, which dissolve in a solution inside the tanks. The company purchases detergent packages with a fill-weight specification of 11.470.08oz. A supplier representative claims that his company uses statistical process control and will promise an inherent process capability of 0.27oz for the fill-weight specification. The brochure says nothing else about the process except that the advertised weight of the detergent packages is 11.5oz.Calculate CpkShould the food processor buy detergent from this supplier? Why or why not?If the supplier had control chart evidence that its fill-weight process was in fact centered a 11.5oz, and was in a state of statistical control, how would your answer to question (a) change? Does all output meet specifications? let a, b e z. (a) prove that if a2 i b2, then a i b. (b) prove that if a n i b n for some positive integer n, then a i b. How does competition affect a consumer's choice in transportation?This question should be based on Jetblue airlines in comparison to other airlines. john meadow rents an apartment and wants tenant's insurance or an ________ policy.