Advertisements
Advertisements
Question
Write a program in Java to display the following pattern:
ABCDE
ABC
A
Answer in Brief
Solution
public class Q12c{
public static void main(String args[])
{
s = "ABCDE";
System.out.printIn("\n\n");
for (int i = s.length() - 1; i >= 0; i = i - 2)
{for (int j = 0; j <= i; j++)
System.out.print(s.charAt(j) + " ");
System.out.printIn();
}
shaalaa.com
Is there an error in this question or solution?
Chapter 2: Library Classes - EXERCISES [Page 180]