logo CodeStepByStep logo

recursionMystery9

Language/Type: C++ recursion
Author: Marty Stepp (on 2016/06/16)

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

int recursionMystery9(int x, int y) {
    if (x < 0) {
        return -recursionMystery9(-x, y);
    } else if (y < 0) {
        return -recursionMystery9(x, -y);
    } else if (x == 0 && y == 0) {
        return 0;
    } else {
        return 100 * recursionMystery9(x / 10, y / 10) + 10 * (x % 10) + y % 10;
    }
}
recursionMystery9(12, 49);
recursionMystery9(73, -8);
recursionMystery9(-248, -3795);

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.