Full Range

Call me (USA Free)

Monday 14 April 2014

Printing Patterns....

Leave a Comment
Q.Write a program to print the following pattern
  
    *
     * *
     * * *
     * * * *
     * * * * *       

public class HalfTriangle
 {
     public void pattern(int n)
      {
          for(int i=1;i<=n;i++) //to define the number of rows
            {
              for(int j=1;j<=i;j++)
               {
                  System.out.print("* ");
                }
             System.out.println();
            }
      } //method
  } //class
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment