KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

A
ab
ABC
abcd
ABCDE

Java

Java Library Classes

ICSE

85 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        for (int i = 65; i < 70; i++) {
            for (int j = 65; j <= i; j++) {
                if (i % 2 == 0)
                    System.out.print((char)(j+32));
                else
                    System.out.print((char)j);
            }
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program in Java to display the following pattern: A ab ABC abcd ABCDE

Answered By

36 Likes