asked 39.4k views
0 votes
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);

asked
User Vhuynh
by
8.0k points

1 Answer

6 votes

Answer:

x = 15 and y = 10

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.

answered
User Adam Lerman
by
8.6k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.