The output I got was 1, 14, 9
Anybody get a different answer from this problem?
Given the function definition
void Twist( 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 involes Twist? (All variables are of type int.)
r = 1;
s = 2;
t = 3;
Twist(t, s);
cout << r << ' ' << s << ' ' << t << endl;
Keep in mind that Twist(t, s);
doesn't change the value of t, since t is passed in as an int
, not an int&
.