-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathStarTriangle.java
More file actions
35 lines (32 loc) · 767 Bytes
/
StarTriangle.java
File metadata and controls
35 lines (32 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package pattern2;
import java.util.Scanner;
/*
for N = 4 print the pattern
*
* * *
* * * * *
* * * * * * *
*/
public class StarTriangle {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int i = 1;
while (i <= n) {
int j = 1;
// number of spaces to be printed
while (j <= n - i) {
System.out.print("\t");
j++;
}
// star printing loop
j = 1;
while (j <= 2 * i - 1) {
System.out.print("*\t");
j++;
}
System.out.println();
i++;
}
}
}