Tuesday, March 23, 2010

Star Pyramid(Nested Loops)

import java.io.*;

public class vfg
{ public static void main(String args[])  
  {  
  int b=4;
  for(int i=1;i<=9;i=i+2)
  { for(int j=1;j<=b;j++)
  { System.out.print(" ");
  }
  for(int k=1;k<=i;k++)
  { System.out.print("*");
  }
  System.out.println();
  b--;
  }
  }
}

2 comments: