Given the function definition void something ( int a, int& b ) { int c; c = a + 2; a = a * 3; b = c + a; } what is the output of the following code fragment that invokes something? (All variables are of type int.) r = 1; s = 2; t = 3; something(t, s); cout << r << ' ' << s << ' ' << t << endl;

Respuesta :

Answer:

The output to the given question is "1, 14, 3".  

Explanation:

In the function definition, we define the function that is something(). In this, we pass two integer parameters in which one is a reference variable. In this function, we define an integer variable that is c and calculate some value.  In the calling time, we define three integer variable that is r, s, t in this variable we assign value that is 1, 2, 3. Then we call the something() function. In this function, we pass two variable that is t,s. and prints its value. In the given function the output is 1, 14, 3. because In the function something(). We use the reference variable that is &b. and all the Changement are done in this variable. and r, t variable value does not change. That's why the output to this function is 1, 14, 3.

ACCESS MORE