Write a java program to print following pattern :
ABCDEFGHI
ABCDEFG
ABCDE
ABC
A
import java.util.Scanner;
public class DecreseCharIncreasingOrder {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter number of rows");
int n=sc.nextInt();
for(int i=0;i<n;i++) {
int k=0;
for(int j=0;j<i;j++) {
System.out.print(" ");
}
for(int j=0;j<2*(n-i)-1;j++)
System.out.print((char)(65+k++)+"");
System.out.println();
}
}
}
Comments
Post a Comment