logo CodeStepByStep logo

You are working on problem set: Week 3 Section ( Pause)

recursionMystery12

Language/Type: C++ recursion

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

void recursionMystery12(int n) {
    if (n == 0) {
        cout << " * " << n;
    } else {
        int a = n % 10;
        if (a % 2 == 0) {
            cout << " + (" << a;
            recursionMystery12(n / 10);
            cout << ")";
        } else {
            recursionMystery12(n / 10);
            cout << " - " << a;
        }
    }
}
recursionMystery12(427);
recursionMystery12(823419605);

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? .

If something seems wrong with our site, please

Is there a problem? Contact us.