Skip to content

Commit 60c7a2f

Browse files
committed
Pattern 44 - TechGig
1 parent fcd4fe6 commit 60c7a2f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.java.patterns;
2+
import java.util.Scanner;
3+
/*
4+
Write the program to print the following pattern
5+
A
6+
A B
7+
A B C
8+
A B C D
9+
A B C D E
10+
*/
11+
public class Pattern44 {
12+
public static void main(String args[] ) throws Exception {
13+
Scanner scanner = new Scanner(System.in);
14+
int N = Integer.parseInt(scanner.nextLine());
15+
String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
16+
for(int i=0;i<N;i++){
17+
for(int j=0;j<=i;j++)
18+
if(j == 0)
19+
System.out.print(s.charAt(j));
20+
else
21+
System.out.print(" "+s.charAt(j));
22+
if(i != N-1)
23+
System.out.println();
24+
}
25+
scanner.close();
26+
}
27+
}
28+
/*
29+
Input
30+
5
31+
Output
32+
A
33+
A B
34+
A B C
35+
A B C D
36+
A B C D E
37+
*/

0 commit comments

Comments
 (0)