logo CodeStepByStep logo

parameterMystery1X

The following code produces 5 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
  • main's e variable is stored at address 0xee00
  • any memory dynamically allocated on the heap will be at address 0x555500
int parameterMystery1X(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 = new int(8);
    int c = -3;
    int d;
    int* e = &a;

    d = parameterMystery1X(a, *b, &c);
    parameterMystery1X(c, d, b);
    parameterMystery1X(*b, *e, &d);

    cout << a << " " << b << " " << *b << " " << c << " " << d << " " << e << " " << *e << endl;
    cout << &a << " " << &b << " " << &c << " " << &d << " " << &e << endl;

    return 0;
}
line 1
line 2
line 3
line 4
line 5

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.