Connect with knowledgeable individuals and get your questions answered on IDNLearn.com. Our experts are ready to provide in-depth answers and practical solutions to any questions you may have.

What is the output of the following code snippet? int i = 1; while (i != 9) { System.out.print(i + " "); i++; if (i == 9) { System.out.println("End"); } } 1 End 1 End 1 End (but the loop is an infinite loop) 1 End (but the loop is an infinite loop) 1 2 3 4 5 6 7 8 End 1 2 3 4 5 6 7 8 End 1 2 3 4 5 6 7 8 End (but the loop is an infinite loop)

Sagot :

Answer:

1 2 3 4 5 6 7 8 End

Explanation:

int i = 1;

while (i != 9){

  System.out.print (i + " ");

  i ++;

  if (i == 9){

     System.out.println("End");

  }

}