Print pattern A BCD EDGHI JKLMNOP
import java.util.Scanner;
public class Pattern {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter n: ");
int n = scanner.nextInt();
char ch = 'A';
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 2 * i - 1; j++) {
System.out.println(ch);
ch++;
}
}
}
}
output
Print pattern
A
BCD
EDGHI
JKLMNOP
No comments:
Post a Comment