logo CodeStepByStep logo

referenceParameterMystery2

What is the output from the following C++ program?

void sentence(string& major, string fred, string& foo) {
    cout << "Many a " << foo << " in the " << fred << " of " << major << endl;
    major[0] = 'X';
    foo[1] = 'Z';
}

int main() {
    string major = "fred";
    string fred = "computer";
    string computer = "department";
    string department = "student";
    string student = "major";

    sentence(major, fred, department);
    sentence(student, department, major);
    sentence(fred, "major", student);
    return 0;
}
output

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.