-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0014-PyramidPattern.java
40 lines (32 loc) · 990 Bytes
/
0014-PyramidPattern.java
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
36
37
38
39
40
// Creator - Yashwant Kargwal
// Don't Forget to ⭐Star and Fork.
// Problem: Create a pyramid pattern with *..
// Output of Pattern :-
// *
// ***
// *****
// *******
// *********
import java.util.Scanner;
class Main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
System.out.println("Program to Print Pyramind Pattern");
System.out.print("Enter Your Rows : ");
int num = sc.nextInt();
System.out.println();
// this loop is used to print the line of pattern
for(int i = 1; i <= num; i++){
// this is used to print space
for(int j = num-1; j >= i;j--){
System.out.print(" ");
}
// this is used to print *
for(int k = 1; k <= (2*i-1); k++){
System.out.print("*");
}
System.out.println();
}
sc.close();
}
}