logo CodeStepByStep logo

parameterMystery1

The following code produces 4 lines of output. What is the output? Write each line of output as it would appear on the console.

For the purposes of this problem, assume that the variables in main are stored at the following memory addresses:

  • main's a variable is stored at address 0xaa00
  • main's b variable is stored at address 0xbb00
  • main's c variable is stored at address 0xcc00
  • main's d variable is stored at address 0xdd00
int parameterMystery1(int a, int& b, int* c) {
    b++;
    a += *c;
    cout << b << " " << *c << " " << a << " " << c << endl;
    c = &a;
    return a - b;
}

int main() {
    int a = 4;
    int b = 8;
    int c = -3;
    int d;

    d = parameterMystery1(a, b, &c);
    parameterMystery1(c, d, &b);
    parameterMystery1(b, a, &d);
    cout << a << " " << b << " " << c << " " << d << endl;

    return 0;
}

line 1
line 2
line 3
line 4

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.