Skip to main content

//Do While

 //Do While


CODE

👇

  1. class Dowhile //class Declaration; class name same as file name. when save in local file.
  2. {
  3. public static void main(String args[]) //Main Method
  4. {
  5. int a = 10; // initializing variables
  6. do
  7. {
  8. System.out.println("the value of a is:"+a); // '+c' is used to indicate which value should be print.
  9. a++;                                       // a++ for this condition 'a <= 20'. value increase upto 20.
  10. }while(a <= 20);                              //(a=10 <= 20) the condition is True; therefore execute conditional code.
  11.                                                      //the condition is true; then control jumps to back 'do', and the loop again ececutes unitl then condition is false.
  12. }
  13. }


👉Execute👈


//Output

/*

the value of a is:10

the value of a is:11

the value of a is:12

the value of a is:13

the value of a is:14

the value of a is:15

the value of a is:16

the value of a is:17

the value of a is:18

the value of a is:19

the value of a is:20

*/



                                     //ThE ProFessoR