Pattern 3


We can print the following Pattern 
1)
A                    //print (char)(j+64)
A B 
A B C 
A B C D 
A B C D E

2)
A                  //print (char)(i+64)
B B 
C C C 
D D D D 
E E E E E 

3)
*                 //print *
* * 
* * * 
* * * * 
* * * * * 

4)
1                     //Print i
2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5 

5)
1                  //print j
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 


package demo;

import java.util.Scanner;

public class Pattern3 {
 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<=n;i++) {
   for(int j=1;j<=i;j++ ) {
    //System.out.print("* ");
    //System.out.print(i+ "5 ");
    //System.out.print(j+ " ");
    //System.out.print((char)(i+64)+ " ");
    System.out.print((char)(j+64)+ " ");
   }
   System.out.println();
    
   }
 } 
 }

O/P:-
Enter the number
5
A 
A B 
A B C 
A B C D 
A B C D E