-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from Diptigit11/patch-2
Create starPyramidPattern.java
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |