Thursday, September 10, 2015

Program to print pattern increasing and decreasing order

public class Pattern3
{
    public static void main(String args[])
    {
        int i,j,r;
        for(i=1;i<=5;i++)
        {
            for(j=1;j<=i;j++)
            {
                System.out.print(j);
            }
            System.out.println();
        }
        for(i=1,r=5-1;i<=5-1;i++,r--)
        {
            for(j=1;j<=r;j++)
            {
                System.out.print(j);
            }
            System.out.println();
        }
    }
}

No comments:

Post a Comment