Thursday, September 10, 2015

Program to print pattern decreasing and increasing order


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

No comments:

Post a Comment