[   ^ to index...   |   <-- previous   ]

Recursion exercises (solutions...)

Pointers review

What does the following print? Can you draw a diagram of the state of the world at each output point?

(For the solution, copy and paste it into a file and run it.)

void shuffle(int a, int *b, int &c) { int temp = a; a = *b; b = &temp; cout << a << ',' << b << ',' << c << endl; c = a + *b + temp; } int main() { int a = 1; int b = 2; int c = 3; shuffle(a, &b, c); cout << a << ',' << b << ',' << c << endl; }

Last modified: Thu Jul 6 14:06:51 PDT 2000