The following function mixes call by reference and call by value parameters.

void T ( int & a, int b )
{ 
	int c = a - 1;
	a = c + b;
	b = a + 2;
}

Suppose that in main we had the following:

int apple = 10;
int banana = 20;
T ( apple, banana );

cout << apple << " " << banana;

What is the output?
a) 29 20
b) 10 31
c) 29 20
d) 29 9
e) 10 20

Recommended Answers

All 2 Replies

What do you think is the answer? Did you compile and test it for yourself? If not, why not?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.