Sunday, June 10, 2012

WHILE LOOP:

 WHILE LOOP:

Syntax: 
     
while( <condition> )
{
        <loop body>
 }

PROGRAM:
public class Example
 {
  public static void main(String[] args) 
  {   
     int i = 0; 
     while(i < 5)
     {
       System.out.println("i is : " + i);
       i++;
     }
  }
}
Output:
i is : 0
i is : 1
i is : 2
i is : 3
i is : 4
TRY YOURSELF: 10
1)Write a java program to display the numbers between 25 and 50 for teaching numbers for Ravi.generate the numbers using while loop.

No comments:

Post a Comment

Animated Social Gadget - Blogger And Wordpress Tips