Skip to content

Commit 648faab

Browse files
authoredOct 22, 2022
Merge pull request #916 from ajay1079/main
star pattern in java
2 parents b54258d + 9bae639 commit 648faab

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
 

‎Java/star.java

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import java.io.*;
2+
3+
// Java code to demonstrate right star triangle
4+
public class star {
5+
// Function to demonstrate printing pattern
6+
public static void StarRightTriangle(int n)
7+
{
8+
int a, b;
9+
10+
// outer loop to handle number of rows
11+
// k in this case
12+
for (a = 0; a < n; a++) {
13+
14+
// inner loop to handle number of columns
15+
// values changing acc. to outer loop
16+
for (b = 0; b <= a; b++) {
17+
// printing stars
18+
System.out.print("* ");
19+
}
20+
21+
// end-line
22+
System.out.println();
23+
}
24+
}
25+
26+
// Driver Function
27+
public static void main(String args[])
28+
{
29+
int k = 5;
30+
StarRightTriangle(k);
31+
}
32+
}

0 commit comments

Comments
 (0)