logo CodeStepByStep logo

parameterMystery2

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 parameterMystery2(string& s1, string s2) {
    s1 += "1";
    s2 += "2";
    cout << s2 << " -- " << s1 << endl;
    return "!" + s2;
}

int main() {
    string a = "hi";
    string b = "bye";
    string c = "yo";

    parameterMystery2(a, c);
    parameterMystery2(c, b);
    string d = parameterMystery2(b, a);

    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?

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.