Skip to content

Commit

Permalink
Merge pull request #171 from Diptigit11/patch-2
Browse files Browse the repository at this point in the history
Create starPyramidPattern.java
  • Loading branch information
sujana-kamasany authored Oct 15, 2023
2 parents d15e392 + 27fd105 commit a864741
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions patterns/starPyramidPattern.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.*;

public class starPyramidPattern {
public static void main(String[] args) {
int n = 5; // we can Change this value to adjust the height of the pyramid

for (int i = 1; i <= n; i++) {
// Print spaces
for (int s = 1; s <= n - i; s++) {
System.out.print(" ");
}

// Print stars
for (int j = 1; j <= i * 2 - 1; j++) {
System.out.print("*");
}

// Move to the next line after each row
System.out.println();
}
}
}

0 comments on commit a864741

Please sign in to comment.