Skip to content

Commit 78db5be

Browse files
committed
feat: Add right-aligned decreasing star pattern using nested loops
🧠 Logic: - Outer loop controls rows (1 to 5). - Inner loop prints either: - "* " if current column (j) ≥ current row (i) - " " (space) otherwise - This creates a right-aligned decreasing triangle of stars. Signed-off-by: Somesh diwan <[email protected]>
1 parent ee029e7 commit 78db5be

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
public class StarPatternsAb {
22
public static void main(String[] args) {
3-
for (int i =1; i<=5; i++)
4-
{
5-
for (int j=1; j<=5; j++)
6-
{
3+
for (int i =1; i<=5; i++) {
4+
for (int j=1; j<=5; j++) {
75
if(i<=j)
86
System.out.print("* ");
97
else
@@ -12,4 +10,4 @@ public static void main(String[] args) {
1210
System.out.println("");
1311
}
1412
}
15-
}
13+
}

0 commit comments

Comments
 (0)