Computer Applications

Write a program to display the pattern:

A B C D E
B C D E
C D E
D E
E

Java

Java String Handling

37 Likes

Answer

public class KboatStringPattern
{
    public static void main(String args[]) {
        String word = "ABCDE";
        int len = word.length();
        
        for (int i = 0; i < len; i++) {
            for (int j = i; j < len; j++) {
                char ch = word.charAt(j);
                System.out.print(ch);
            }
            System.out.println();
        }
    }
}

Variable Description Table

Program Explanation

Output

Answered By

12 Likes


Related Questions