Pattern Type Two Program in Java


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

Output:

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


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

Output:

55555
4444
333
22
1


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

Output:

12345
1234
123
12
1


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

Output:

11111
0000
111
00
1


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

Output:

10101
1010
101
10
1


public class Pattern16
{
    public static void main(String[] args)
    {
        int k;
        for (int i = 5; i >= 1; i--)
        {
            k = i;
            for (int j = 1; j <= i; j++)
            {
                System.out.print((k+1) % 2);
                k++;
            }
            System.out.println();
        }
    }
}


Output:

01010
1010
010
10
0


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

Output:

1 2 3 4 5 
6 7 8 9 
10 11 12 
13 14 
15 


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

Output:

5 6 7 8 9 
4 5 6 7 
3 4 5 
2 3 
1


public class Pattern19
{
    public static void main(String[] args)
    {
        int k;
        for (int i = 5; i >= 1; i--)
        {
            k = i;
            for (int j = 1; j <= i; j++)
            {
                System.out.print(k % 2);
                k++;
            }
            System.out.println();
        }
    }
}

Output:

10101
0101
101
01
1 


public class Pattern20
{
    public static void main(String[] args)
    {
        for (int i = 5; i >= 1; i--)
        {
            for (int j = 1; j <= i; j++)
            {
                if (i % 2 == 0)
                {
                    System.out.print("#");
                }
                else
                {
                    System.out.print("*");
                }
            }
            System.out.println();
        }
    }
}

Output:

*****
####
***
##
*
b. tech. bca icse java java tutorials learn java mca programs