Go to Top

Tuesday 2 August 2011

To print the given pattern

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


1
21
321
4321
54321

Java Program : 

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

No comments:

Post a Comment

ShareThis