Skip to content

Commit 686ca40

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#139 from adityakumar007/patch-1
nested for loops
2 parents e74dded + 82d644e commit 686ca40

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

pattern

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package Pattern;
2+
import java.util.Scanner;
3+
4+
public class Pattern {
5+
6+
public static void main(String[] args) {
7+
Scanner sc= new Scanner(System.in);
8+
int n=sc.nextInt();
9+
System.out.println("*");
10+
11+
12+
13+
14+
for(int i=2;i<=n-1;i++) {
15+
System.out.print("* ");
16+
17+
for(int j=1;j<=i-2;j++) {
18+
System.out.print(" ");
19+
}
20+
System.out.print("* ");
21+
System.out.println();
22+
}
23+
24+
for(int i=1;i<=n;i++) {
25+
System.out.print("* ");
26+
}
27+
28+
}
29+
30+
}

0 commit comments

Comments
 (0)