Print the Alphabets A to Z in the Right Alphabetic Triangle Pattern

To Print the Alphabets A to Z in the Right Alphabetic Triangle Pattern, we are use below step :-

  • Create Scanner class object to pass input data.
  • Initialize a character c=65 for print A
  • Declare one for loop which is iterate at depend on input data value.
  • Now first for loop inside another for loop for iterate.
  • Inside Second for loop we add initialize character value and index value of j.
  • Now convert both value in character.
				
					import java.util.Scanner;

public class AlphabetPattern {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter the number of rows:");
		int n = sc.nextInt();
		int c = 65;
		System.out.println("Right Alphabetic Triangle Pattern :- ");
		for (int i = 1; i <= n; i++) {

			for (int j = 0; j < i; j++) {
				System.out.print((char) (c + j));
			}
			System.out.println();
		}

	}

}
				
			

Output :- Enter the number of rows :
5
Right Alphabetic Triangle Pattern :-
A
AB
ABC
ABCD
ABCDE