KnowledgeBoat Logo

Java Pattern Programs

Write a program in Java to display the following pattern:

PRTV
PRT
PR
P

Java

Java Library Classes

ICSE

26 Likes

Answer

public class KboatPattern
{
    public static void main(String args[]) {
        for (int i = 86; i >= 80; i = i - 2) {
            for (int j = 80; j <= i; j = j + 2) {
                System.out.print((char)j);
            }
            System.out.println();
        }
    }
}

Output

BlueJ output of Write a program in Java to display the following pattern: PRTV PRT PR P

Answered By

13 Likes