logo CodeStepByStep logo

loop_mystery_exam3

Language/Type: C while return

For each call of the function below, write the output that is printed and the value that is returned:

int loop_mystery_exam3(int x, int y) {
    int z = x + y;
    while (x > 0 && y > 0) {
        x = x - y;
        y--;
        printf("%d %d ", x, y);
    }
    printf("%d\n", y);
    return z;
}
loop_mystery_exam3(7, 5) output
loop_mystery_exam3(7, 5) return
loop_mystery_exam3(20, 4) output
loop_mystery_exam3(20, 4) return
loop_mystery_exam3(40, 10) output
loop_mystery_exam3(40, 10) return

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.