What will be the output of the following while loop?

Last Updated :
Discuss
Comments

What will be the output of the following while loop?

Java
int x = 10;
while (x > 0) {
    x -= 3;
    System.out.print(x + " ");
}


7 4 1 -2

10 7 4 1

10 7 4 1 -2 -5

Infinite loop

Share your thoughts in the comments