Sunday, February 24, 2013

sample While loop


public class act1 {

    public static void main(String[] args) {
       
       
        int d=1;
        while( d<=5)
        {
            d++;
            int j=1;
           
            while( j<=d)
            {
                           
                System.out.print(" * ");
                j++;
            }
           
            System.out.println();
        }
       
       
        int i=1;
        while( i<=5 )
        {
            i++;
           
            int j=i;
           
            while( j<=6 )
            {
           
                System.out.print(" * ");
                j++;
            }
           
            System.out.println();
           
        }
       
       
    }

}

No comments:

Post a Comment