logo CodeStepByStep logo

recursionMysteryComma

Language/Type: C++ recursion

For each call to the following recursive function, write the output that would be produced, as it would appear on the console.

void recursionMysteryComma(int x, int y) {
    if (y == 1) {
        cout << x;
    } else {
        cout << (x * y) << ", ";
        recursionMysteryComma(x, y - 1);
        cout << ", " << (x * y);
    }
}
recursionMysteryComma(4, 1);
recursionMysteryComma(4, 2);
recursionMysteryComma(8, 2);
recursionMysteryComma(4, 3);
recursionMysteryComma(3, 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.