Skip to content

Commit 857ae5d

Browse files
committed
feat: Create right-aligned lower triangle star pattern using i + j > 5 condition
🧠 Logic: - Outer loop runs for rows (1 to 5). - Inner loop runs for columns (1 to 5). - If (i + j > 5), print a star (`* `); else, print double space. - This results in a right-aligned triangle formed by stars in the lower half. Signed-off-by: Somesh diwan <[email protected]>
1 parent d50a40a commit 857ae5d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
public class StarPatternsAB4 {
22
public static void main(String[] args) {
33
for (int i = 1; i <= 5; i++) {
4-
for (int j = 1; j <= 5; j++) {
4+
for (int j = 1; j <= 5; j++)
5+
{
56
if (i + j > 5)
67
System.out.print(("* "));
78
else
89
System.out.print(" ");
910
}
10-
1111
System.out.println("");
12-
1312
}
1413
}
1514
}

0 commit comments

Comments
 (0)