Entry and Exit Control Loop

Entry and Exit Control loop

We already know basic structure of for, while and do..while loop in our last blog. We also know about entry and exit control loop in last blog. So in this blog we will discuss on how to use these loops in our languages.

In this blog, I give four programs in one simple program. Using of this program we understand basic structure of loop. And also see the different between them.

Normally three loops work same, but writing structures are different.

Let’s see the simple program on it.

 

Program on for, while and do while – Entry and Exit Control Loop

class loop1

{

          public static void main(String args[])

          {

                   int i;

                   System.out.println(“For Loop”);

                   for(i=1;i<=10;i++)

                   {

                             System.out.print(i + “ ”);

                   }

                   System.out.println(“\n\nFor Loop”);

                   i=10;

                   for(;i>=1;)

                   {

                             System.out.print(i + “ ”);

                             i–;

                   }

                   System.out.println(“\n\nWhile Loop”);

                   i=65;

                   while(i<=75)

                   {

                             System.out.print(i + “ ”);

                             i++;

                   }

                   System.out.println(“\n\nDo…while Loop”);

                   i=65;

                   do

                   {

                             System.out.print(i + “ ”);

                             i++;

                   }

                   while(i<=75);

          }

}

Output:

For Loop

1 2 3 4 5 6 7 8 9 10

For Loop

10 9 8 7 6 5 4 3 2 1

While Loop

65 66 67 68 69 70 71 72 73 74 75

Do…While Loop

65 66 67 68 69 70 71 72 73 74 75

 

If you have problem on this blog, you can directly comment on it.

420total visits,6visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

1 Comment

  1. September 20, 2016 - 3:45 am

    Woah! I’m really enjoying the template/theme of this website.
    It’s simple, yet effective. A lot of times it’s very hard to get
    that “perfect balance” between user friendliness and
    visual appeal. I must say that you’ve done a very good job with this.
    Also, the blog loads extremely quick for me on Firefox. Superb Blog! http://bing.co.uk

Leave a Reply

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

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.

Website

Link back if you want.

Enter Captcha Here :*

Reload Image