KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

A
ab
ABC
abcd
ABCDE

Java

Java Library Classes

106 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();
        }
    }
}

Variable Description Table

Program Explanation

Output

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

Answered By

44 Likes