We can print the following Pattern
1)
1 //print (char)(j+64) and i
A B
3 3 3
A B C D
2)
1 //print (char)(j+64) and j
A B
1 2 3
A B C D
3)
1 //print (char)(i+64) and i
B B
3 3 3
D D D D
4)
1 //print (char)(i+64) and j
B B
1 2 3
D D D D
package demo;
import java.util.Scanner;
public class Pattern9 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number");
int n=sc.nextInt();
for(int i=1;i=i;k--) {
System.out.print(" ");
}
for(int j=1;j<=i;j++) {
//System.out.print("* ");
if(i%2 == 0) {
System.out.print((char)(i+64)+ " ");
}
else
{
System.out.print(j+ " ");
}
}
System.out.println();
}
}
}
O/P:-
Enter the number
5
1
A B
3 3 3
A B C D