< previous page page_379 next page >

Page 379
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
    cin >> z >> x >> a;
    a = z * x + a;
}
11. The program below has a function named Change. Fill in the values of all variables before and after the function is called. Then fill in the values of all variables after the return to the main function. (If any value is undefined, write u instead of a number.)
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
#include <iostream.h>

void Change( int, int& );

int main()
{
    int a;
    int b;

    a = 10;
    b = 7;
    Change(a, b);
    cout << a <<   << b << endl;
    return 0;
}

void Change( int x,
             int& y )
{
    int b;

    b = x;
    y = y + b;
    x = y;
}
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Variables in main just before Change is called:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a _____
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b _____
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Variables in Change at the moment control enters the function:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
x _____
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
y _____
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b _____
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Variables in main after return from Change:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a _____
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b _____

 
< previous page page_379 next page >