logo CodeStepByStep logo

loop_mystery_exam1

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_exam1(int i, int j) {
    while (i != 0 && j != 0) {
        i = i / j;
        j = (j - 1) / 2;
        printf("%d %d ", i, j);
    }
    printf("%d\n", i);
    return i + j;
}
loop_mystery_exam1(5, 0) output
loop_mystery_exam1(5, 0) return
loop_mystery_exam1(3, 2) output
loop_mystery_exam1(3, 2) return
loop_mystery_exam1(16, 5) output
loop_mystery_exam1(16, 5) return
loop_mystery_exam1(80, 9) output
loop_mystery_exam1(80, 9) return
loop_mystery_exam1(1600, 40) output
loop_mystery_exam1(1600, 40) 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.