Skip to content

Commit 297ff2b

Browse files
committed
feat: Print right-angled triangle star pattern using nested loops
🧠 Logic: - Use two nested `for` loops to print a right-angled triangle made of `*`. - Outer loop (`i`) runs from 0 to 5 (6 rows total). - Inner loop (`j`) runs from 0 to `i`, printing `*` in each iteration. - After printing stars for one row, move to the next line using `println()`. - Output: * ** *** **** ***** ****** Signed-off-by: Somesh diwan <[email protected]>
1 parent ec43a17 commit 297ff2b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
public class StarNestedLoop
2-
{
3-
public static void main(String[] args)
4-
{
5-
for(int i =0; i<6; i++)
6-
{
7-
for(int j=0; j<= i; j++)
8-
{
1+
public class StarNestedLoop {
2+
public static void main(String[] args) {
3+
for(int i =0; i<6; i++) {
4+
for(int j=0; j<= i; j++) {
95
System.out.print("*");
106
}
117
System.out.println();
128
}
139
}
14-
}
10+
}

0 commit comments

Comments
 (0)