Solved

While Loop Simulation
for Each Call of the Method Below

Question 7

Essay

While Loop Simulation
For each call of the method below, write the output that is printed:
public static void mystery(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);
}
 Method Call  Output mystery (5,0)       mystery (3,2)       mystery (16,5)       mystery (80,9)       mystery (1600,40)      \begin{array}{l}\underline{ \text { Method Call } }& \underline{ \text { Output}} \\\text { mystery }(5,0) & \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \\\text { mystery }(3,2) & \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }}\\\text { mystery }(16,5) & \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }}\\\text { mystery }(80,9) & \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \\\text { mystery }(1600,40) & \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \underline{ \text { }} \end{array}

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents