Step-by-step explanation:
so, what's the question/problem ?
you want to know where the bubbles are after all 4 passes ? right at the original position.
you want to know, how such a while loop could look like ?
int i = 3;
// outer count-down to limit the passes
while (i >= 0) // making 4 passes
{
int j = i;
// inner count-down to limit the right moves
while (j > 0)
{
move(bubble1, right, 1);
move(bubble2, right, 1);
j = j - 1; // count-down
}
j = i;
// inner count-down to limit the left moves
while (j > 0)
{
move(bubble1, left, 1);
move(bubble2, left, 1);
j = j - 1; // count-down
}
i = i - 1; // outer count-down
}