Go to Top

Tuesday 2 August 2011

To print the given pattern

Question 26 : Write a program in Java to print the following pattern : 

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

Java Program : 

public class pattern_13
{
 public static void main()
 {
     int i,j;
     for(i=1;i<=5;i++)
     {
         for(j=1;j<=i;j++)
         {
         System.out.print("*");
         }
        System.out.print("\n");
     }
 }
}

No comments:

Post a Comment

ShareThis