Do while loop to print numbers from 0 to 10

  1. The class is declared as Dowhileloop.
  2. The main method is declared as public static void main(String[] args).
  3. An integer variable i is initialized with a value of 0.
  4. The do-while loop is started using the do keyword.
  5. Inside the loop, the current value of i is printed using System.out.println(i).
  6. The value of i is incremented by 1 using i = i + 1.
  7. The condition i < 11 is checked, and if it evaluates to true, the loop continues. Otherwise, the loop is terminated.
  8. Since the condition initially holds true (0 < 11), the loop will execute until i becomes 11.
  9. Once i reaches 11, the loop terminates, and the program ends
public class Dowhileloopaapnaclg {
    public static void main(String[] args){
        
   int i = 0;

        do {

            System.out.println(i);
            i = i + 1;
        } 
        while (i < 11);


        }
    }
    

Add a Comment

Your email address will not be published. Required fields are marked *