Output must be 1 2 3 4 5 6 7 8 9 10
I have tried While loop but it prints from 10 to 1
Advertisement
Answer
Assuming you must use i
with an initial value of 10
.
for(int i = 10; i > 0; i--) { System.out.println(11-i); } // or using a while loop int i = 10; while(i > 0) { System.out.println(11-i--); }