Java Online Compiler
Example: Left-Aligned Alphabet Triangle in Java
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Left-Aligned Alphabet Triangle import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the number of rows for the left-aligned triangle: "); int rows = scanner.nextInt(); // Outer loop for each row for (int i = 0; i < rows; i++) { // Inner loop to print increasing alphabets for (int j = 0; j <= i; j++) { System.out.print((char) ('A' + j)); } System.out.println(); // Move to the next line } scanner.close(); } }
Output
Clear
ADVERTISEMENTS