Video 22 (ch5)

Yash
0

 



Program:-

https://drive.google.com/file/d/1jvslH5U1ZU4vH_3OK-rSSQko1cSPgQpB/view?usp=drivesdk


public class Main {

public static void main(String[] args) {

//Printing 0 to 5 using do-while loop.

System.out.println("The numbers from 0 to 5 is as follows:");

int a = 0;

do{

    System.out.println(a);

    a++;

    }while(a<5);

    //The do-while loop first check the execute the code and then check the condiion is true or false so here we see that the 10 if printed even if the condition is false.

    System.out.println("imp:<");

    int b = 10;

    do{

        System.out.println(b);

        b++;

        }while(a<5);

//quick quiz 

//Q.write a program to print first 101 natural numbers using do-while loop.

System.out.println("The numbers form 0 to 101 are as follows:");

int c = 0;

do{

    System.out.println(c);

    c++;

    }while(c<=101);

}

}

Post a Comment

0 Comments
Post a Comment (0)
To Top