Thursday, 7 June 2012




class StarsTest
 public static void main(String args[])
 {
  int stars=1,lines=5,spaces=5;
  int i=1,j,k;
  for(i=0;i<lines;i++)
  {
   // print spaces first
  for(k=0;k<spaces;k++)
  System.out.print(" ");
for(j=0j<(stars);j++)                                 System.out.print("*"); 
                                          
spaces--;  
stars +=1;
System.out.println( );         
        }         
    }
}

D:\mywork>javac StarsTest.java
D:\mywork>java StarsTest

                        *
                     *    *
                  *    *    *
               *    *     *   *
           *    *     *     *    *

0 comments:

Post a Comment

Blogroll

Blogger templates

About