logo CodeStepByStep logo

parameterMystery6

Author: Marty Stepp (on 2016/06/19)

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

string parameterMystery6(int a, int& b, string& c, string d) {
    a++;
    b++;
    c += "x";
    d += "x";
    cout << d << " " << c << " " << b << " " << a << endl;
    return d;
}

int main() {
    int a = 1;
    int b = 20;
    int x = 300;
    string c = "c";
    string d = "d";
    string z = "z";

    parameterMystery6(a, b, c, d);
    parameterMystery6(b, x, z, c);
    d = parameterMystery6(x, a, c, z);

    cout << a << " " << b << " " << x << " " << c << " " << d << " " << z << endl;
    return 0;
}
line 1
line 2
line 3
line 4

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.