Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Monday, 27 June 2011

Java program using while loop


import java.util.*;
class loop
{
public static void main (String arg[])
{
Scanner in = new Scanner (System.in);
int a=10;
while (a<=20)
{
System.out.print ("\n\t a = "+a);
++a;
}

}
}

Remember, while a is less than or equal to 20 body of the loop will be executed. Once a equals to 21, loop will be broken and control goes to the next statement after that loop.

No comments:

Post a Comment