void Pancake(int x, int& y, int z); void Waffle(int& x, int& y); int Doughnut(in
ID: 3570857 • Letter: V
Question
void Pancake(int x, int& y, int z);
void Waffle(int& x, int& y);
int Doughnut(int y, int z);
int main( )
{
int a = 1;
int b = 2;
int c = 3;
int d = 4;
Pancake(a, b, c);
Waffle(b, c);
Pancake(d, c, b);
d = Doughnut(b, a);
return 0;
}
void Pancake(int x, int& y, int z)
{
y += 3; z = x + y;
}
void Waffle(int& x, int& y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int Doughnut(int y, int z)
{
int w;
w = y * 2;
z = w + 3;
w --;
return w;
}
What are the values of a,b,c,d after the first call to function Pancake?
What are the values of a,b,c,d after the call to function Waffle?
What are the values of a,b,c,d after the second call to function Pancake?
What are the values of a,b,c,d after the call to function Doughnut?
Explanation / Answer
int a = 1;
int b = 2;
int c = 3;
int d = 4;
1) a =1 b=5 c=3 d=4 //only value of b chage since it is passed by reference and added 3
2) a =1 b=3 c=5 d=4 // b and c are exchanged which are passed by reference
3) a =1 b=3 c=8 d=4 // only value of c chage since it is passed by reference and added 3
4) a =1 b=3 c=8 d=5
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.