Java Program to Print Right Triangle Alphabets Pattern

Write a Java program to print right angled triangle alphabets pattern using for loop.

package Alphabets;

import java.util.Scanner;

public class RightTriangleAlphabets1 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		System.out.print("Right Triangle Alphabets Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Right Triangle Alphabets Pattern");
		int alphabet = 65;
		
		for (int i = 0 ; i < rows; i++ ) 
		{
			for (int j = 0 ; j <= i; j++ ) 	
			{
				System.out.print((char)(alphabet + j) + " ");
			}
			System.out.println();
		}
	}
}
Java Program to Print Right Triangle Alphabets Pattern

This Java example displays the alphabets in right angled triangle pattern using a while loop.

package Alphabets;

import java.util.Scanner;

public class RightTriangleAlphabets2 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		System.out.print("Right Triangle Alphabets Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Right Triangle Alphabets Pattern");
		int alphabet = 65, i = 0, j;
		
		while( i < rows ) 
		{
			j = 0 ; 
			while (j <= i ) 	
			{
				System.out.print((char)(alphabet + j) + " ");
				j++;
			}
			System.out.println();
			i++;
		}
	}
}
Right Triangle Alphabets Pattern Rows = 9
Printing Right Triangle Alphabets Pattern
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 
A B C D E F G H 
A B C D E F G H I 

Java program to print right triangle alphabets pattern using do while loop.

package Alphabets;

import java.util.Scanner;

public class RightTriangleAlphabets3 {

	private static Scanner sc;
	
	public static void main(String[] args) {
		
		sc = new Scanner(System.in);	
		
		System.out.print("Right Triangle Alphabets Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Right Triangle Alphabets Pattern");
		int alphabet = 65, i = 0, j;
		
		do
		{
			j = 0 ; 
			do 	
			{
				System.out.print((char)(alphabet + j) + " ");
				
			} while (++j <= i) ;
			
			System.out.println();

		} while( ++i < rows );
	}
}
Right Triangle Alphabets Pattern Rows = 14
Printing Right Triangle Alphabets Pattern
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 
A B C D E F G H 
A B C D E F G H I 
A B C D E F G H I J 
A B C D E F G H I J K 
A B C D E F G H I J K L 
A B C D E F G H I J K L M 
A B C D E F G H I J K L M N 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.