Skip to main content

#loop #typesofloop What is loop | How to use loop | Type of loop | comp...

What is loop | Types of loop | When should you choose loop | when you decide to good for loop | What is the need of loop.

If you want to know about the loop than learn to hear. I am going to introduce the loop.
Q1.What is loop
 Ans: Loop is a technique to execute a block of statements multiple times. we can if you want to execute the statement multiple times then keep this statement inside the loop. through the loop, we can reduce the length of the program and the complexity of the code. types of loop.


Types of the loop:

   Basically, the loop is two types of 1.exit control loop and the other one is 2.entery control loop
   1.Exit control loop-
       The loop which is control after execution than goes for the exit control loop.
       like- do-while loop
         class A{
          
         public static void main(String args[]){
             int i=1;
             do{
                        System.out.println("Hello");
           }while(i++<10);
         }
       
     }
   So, In this example, you know the syntax of the do-while loop.

2.Entry control loop:
   
      In the entry control loop, you have to check the condition first then come inside the loop. if the condition is true.
like:  while() loop and for() loop.

So, I am going to introduce both for() loop and while loop syntax.
for() loop: If you know the ending point of iteration or how many times you have to iterate than go for() loop.

    class A{

        public static void main(String args[]){
         
         for(int i=0;i<10;i++){
            System.out.println("Hello");
           }
       }

}

In this example, you already know how many times you have to iterate the loop then choose the for a loop.

While() loop: If you don't how many times you have to iterate the loop then go for a while() loop because all the conditions are we don't know about this.

  class A{

      public static void main(String args[]){
       
         int i=10;
         while(i!=0){
             System.out.println("Hello");
             i=i/2;
          }
    }
 }
 





    

Comments

Popular posts from this blog

Difference between Traditional programming languages and object-oriented programming languages..?

 What are Traditional programming languages and object-oriented programming languages..? or Difference between Traditional programming language  and object-oriented programming language Here....what is Traditional programming language and object-oriented programming language..? or Difference between Traditional programming language to help you make the new concepts, you are learning            as a beginner to  become a Master in any programming it's really very most important: Traditional programming language 1.Traditional computer programming has been around for more than a      century, with the first known computer program dating back to the mid-1800s.  2.Traditional Programming refers to any manually created program     that uses input data and runs on a computer to produce the output. 3.But for decades now, an advanced type of programming has revolutionized     business, particularly in ...

Top 50 HTML Interview Question (Most popular in the interview) | important html interview question

😀  Hello everyone. As you all know that to build a software project there are 3 Major categories to develop.😂 1.Front End  2.Middle Ware 3.Back End To crack the interview in front-end technology am going to give top FAQs which take place in your interview.so... Let's start now. TOPMOST FAQ's IN HTML   The first question raised by the interviewer is 1)What is HTML? HTML is a HyperText Markup Language. It is used for the creation and display of attractive, interactive, and dynamic web pages. By Tim Berners Lee's father of web environment. 2)What is the importance of Doctype in HTML? ​It is written at the top of the HTML document.​It is not a tag.​It tells the browser about the HTML version. 3)Define a TAG. ​A Tag or Element is said to be the text placed between Left angular brace " <" and right angular brace " >".   Syntax :   < .......... >    :     < html>   Do you know there are two types of ...

Miner Project | Major project for college Students | B.E, MCA, B-tech Student project in college

                        Miner Project | Major project college  Student for majors and miner project to submit the college and university. we can submit this project to final year students and third-year also?     Download project