Skip to content

Commit fcd4fe6

Browse files
committed
Pattern 43 - TechGig
1 parent b406c87 commit fcd4fe6

File tree

1 file changed

+36
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)