logo CodeStepByStep logo

You are working on problem set: Assignment 28 ( Pause)

loopMysteryExam1

Language/Type: Java while return

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

public static int loopMysteryExam1(int i, int j) {
    while (i != 0 && j != 0) {
        i = i / j;
        j = (j - 1) / 2;
        System.out.print(i + " " + j + " ");
    }
    System.out.println(i);
    return i + j;
}
loopMysteryExam1(5, 0) output
loopMysteryExam1(5, 0) return
loopMysteryExam1(3, 2) output
loopMysteryExam1(3, 2) return
loopMysteryExam1(16, 5) output
loopMysteryExam1(16, 5) return
loopMysteryExam1(80, 9) output
loopMysteryExam1(80, 9) return
loopMysteryExam1(1600, 40) output
loopMysteryExam1(1600, 40) return

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.