Computer Applications

Write a program in Java to display the following pattern:

AAAAA
BBBB
CCC
DD
E

Java

Java Nested for Loops

14 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        
        for (char i = 'A'; i <= 'E'; i++) {
            for (int j = i; j <= 'E'; j++) {
                System.out.print(i);
            }
            System.out.println();
        }
    }
}

Output

Answered By

9 Likes