Suppose that you have the following function. void mystery(int& one, int two) { int temp temp = one; one = two; two = temp; } What are the values of x and y after the following statements? (Assume that variables are properly declared.) x = 10; y = 15; mystery(x, y);

Respuesta :

Answer:

x = 15 and y = 10

Step-by-step explanation:

It is assumed that 'x' and 'y' are declared as '10' and '15' respectively. Then following the mystery(x, y) function which is pass 10 and 15 as parameter. Then we can follow the logic of the mystery function.

First, temp is assigned to one; that is temp = 10

Secondly, one is assigned to two; that is one = 15

Thirdly, two is assigned to temp; that is two = 10.

Since x and y is same as one and two; we say:

x = one = 15  and

y = two = 10.