Blog

  • Inverted Right Triangle Alphabet Pattern in Java: Pattern 5

    Inverted Right Triangle Alphabet Pattern in Java: Pattern 5

    In this tutorial, we will write a java program to display the reverse right triangle pattern using the alphabet. These are character pattern programs in java. Before that, you may go through the following topic in java.

    The program below takes the user input from the user for the number of rows and displays the reverse right triangle character pattern in various character orders.

    This program can also be called the inverted half pyramid in java or Floyd’s triangle alphabet pattern in java.

    Reverse right angled triangle pattern

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        int ch = 64;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        System.out.print("Output:\n");
        for (i = rows; i >= 1; i--)
        {
          for (j = i; j >= 1; j--)
            System.out.print((char)(j + ch));
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 6
    Output:
    FEDCBA
    EDCBA
    DCBA
    CBA
    BA
    A


  • Inverted Right Triangle Alphabet Pattern in Java: Pattern 4

    Inverted Right Triangle Alphabet Pattern in Java: Pattern 4

    In this tutorial, we will write a java program to display the reverse right triangle pattern using the alphabet. These are character pattern programs in java. Before that, you may go through the following topic in java.

    The program below takes the user input from the user for the number of rows and displays the reverse right triangle character pattern in various character orders.

    This program can also be called the inverted half pyramid in java or Floyd’s triangle alphabet pattern in java.

    Pattern 4: Reverse right angled triangle pattern

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        int ch = 64;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        System.out.print("Output:\n");
        for (i = rows; i >= 1; i--)
        {
          for (j = 1; j <= i; j++)
            System.out.print((char)(i + ch));
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 5
    Output:
    EEEEE
    DDDD
    CCC
    BB
    A


  • Inverted Right Triangle Alphabet Pattern in Java: Pattern 3

    Inverted Right Triangle Alphabet Pattern in Java: Pattern 3

    In this tutorial, we will write a java program to display the reverse right triangle pattern using the alphabet. These are character pattern programs in java. Before that, you may go through the following topic in java.

    The program below takes the user input from the user for the number of rows and displays the reverse right triangle character pattern in various character orders.

    This program can also be called the inverted half pyramid in java or Floyd’s triangle alphabet pattern in java.

    Reverse right angled triangle pattern

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        int ch = 64;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        System.out.print("Output:\n");
        for (i = 1; i <= rows; i++)
        {
          for (j = rows; j >= i; j--)
            System.out.print((char)(i + ch));
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 6
    Output:
    AAAAAA
    BBBBB
    CCCC
    DDD
    EE
    F


  • Inverted Right Triangle Alphabet Pattern in Java: Pattern 2

    Inverted Right Triangle Alphabet Pattern in Java: Pattern 2

    In this tutorial, we will write a java program to display the reverse right triangle pattern using the alphabet. These are character pattern programs in java. Before that, you may go through the following topic in java.

    The program below takes the user input from the user for the number of rows and displays the reverse right triangle character pattern in various character orders.

    This program can also be called the inverted half pyramid in java or Floyd’s triangle alphabet pattern in java.

    Reverse right angled triangle pattern

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        int ch = 64;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        System.out.print("Output:\n\n");
        for (i = 1; i <= rows; i++)
        {
          for (j = rows; j >= i; j--)
            System.out.print((char)(j + ch));
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 7
    Output:


    GFEDCBA
    GFEDCB
    GFEDC
    GFED
    GFE
    GF
    G


  • Alphabet Pyramid Pattern in Java: pattern 3

    Alphabet Pyramid Pattern in Java: pattern 3

    In this tutorial, we will write a Java program to display alphabet pyramid patterns. Before that, you may go through the following topic in java.

    Trianglular alphabet pattern

    This is a program the pattern is that the alphabet starts with A and at every increment of the row there is an increment in alphabet such as A, AB, ABC, and so on.

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        Scanner scan = new Scanner(System.in);
    
        System.out.print("Enter the number of rows: ");
        rows = scan.nextInt();
    
        System.out.print("Output:\n");
        for (i = 1; i <= rows; i++)
        {
          for (j = 1; j <= rows - i; j++)
            System.out.print(" ");
    
          for (j = 1; j <= i; j++)
            System.out.print((char)(char)(j + 64) + " ");
    
          System.out.println();
        }
      }
    }
    Enter the number of rows: 7
    Output:
          A
         A B
        A B C
       A B C D
      A B C D E
     A B C D E F
    A B C D E F G

  • Alphabet Pyramid Pattern in Java: pattern 2

    Alphabet Pyramid Pattern in Java: pattern 2

    In this tutorial, we will write a Java program to display alphabet pyramid patterns. Before that, you may go through the following topic in java.

    Trianglular alphabet pattern

    This is a program the right half and left half remain exactly the same on each row forming a triangular pyramid.

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        Scanner scan = new Scanner(System.in);
    
        System.out.print("Enter the number of rows: ");
        rows = scan.nextInt();
    
        System.out.print("Output:\n\n");
        for (i = 1; i <= rows; i++)
        {
          for (j = 1; j <= rows - i; j++)
            System.out.print(" ");
    
          //left half
          for (j = i; j > 0; j--)
            System.out.print((char)(j + 64));
    
          //right half
          for (j = 2; j <= i; j++)
            System.out.print((char)(j + 64));
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the number of rows: 8
    Output:
         
           A
          BAB
         CBABC
        DCBABCD 
       EDCBABCDE
      FEDCBABCDEF
     GFEDCBABCDEFG
    HGFEDCBABCDEFGH

  • Square Number Pattern in Java: 10

    Square Number Pattern in Java: 10

    In this tutorial, we will go through the square number pattern program in java. Before that, you may go through the following topic in java.


    Number Square Pattern Programs in Java

    The programs below take the user input for the number of rows to be displayed in the pattern. We have used a for loop to iterate.

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        for (i = 1; i <= 5; i++)
        {
          for (j = 1; j <= 5; j++)
          {
            if (j <= i)
              System.out.print(i + " ");
            else
              System.out.print(j + " ");
          }
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 5
    1 2 3 4 5
    2 2 3 4 5
    3 3 3 4 5
    4 4 4 4 5
    5 5 5 5 5


  • Square Number Pattern in Java: 9

    Square Number Pattern in Java: 9

    In this tutorial, we will go through the square number pattern program in java. Before that, you may go through the following topic in java.


    Number Square Pattern Programs in Java

    The programs below take the user input for the number of rows to be displayed in the pattern. We have used a for loop to iterate.

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j, k;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        for (i = 1; i <= rows; i++)
        {
          j = (i *2) - 1;
    
          for (k = i; k <= rows; k++)
          {
            System.out.print(j + " ");
            j += 2;
          }
    
          for (j = (i *2) - 3; j >= 1; j -= 2)
            System.out.print(j + " ");
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 5
    1 3 5 7 9
    3 5 7 9 1
    5 7 9 3 1
    7 9 5 3 1
    9 7 5 3 1


  • Square Number Pattern in Java: 8

    Square Number Pattern in Java: 8

    In this tutorial, we will go through the square number pattern program in java. Before that, you may go through the following topic in java.


    Number Square Pattern Programs in Java

    The programs below take the user input for the number of rows to be displayed in the pattern. We have used a for loop to iterate.

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j, k;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        for (i = 1; i <= rows; i++)
        {
          j = (i *2) - 1;
    
          for (k = 1; k <= rows; k++)
          {
            System.out.print(j + " ");
            j += 2;
    
            if (j > (rows *2) - 1)
              j = 1;
          }
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 5
    1 3 5 7 9
    3 5 7 9 1
    5 7 9 1 3
    7 9 1 3 5
    9 1 3 5 7


  • Square Number Pattern in Java: 7

    Square Number Pattern in Java: 7

    In this tutorial, we will go through the square number pattern program in java. Before that, you may go through the following topic in java.


    Number Square Pattern Programs in Java

    The programs below take the user input for the number of rows to be displayed in the pattern. We have used a for loop to iterate.

    import java.util.Scanner;
    
    public class Main
    {
      public static void main(String args[])
      {
        int rows, i, j;
        Scanner sc = new Scanner(System.in);
    
        System.out.print("Enter the no. of rows: ");
        rows = sc.nextInt();
    
        for (i = 1; i <= rows; i++)
        {
          for (j = i; j <= rows; j++)
            System.out.print(j + " ");
    
          for (j = i - 1; j >= 1; j--)
            System.out.print(j + " ");
    
          System.out.println();
        }
      }
    }

    Output:

    Enter the no. of rows: 5
    1 2 3 4 5
    2 3 4 5 1
    3 4 5 2 1
    4 5 3 2 1
    5 4 3 2 1