This repository has been archived by the owner on Dec 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecde276
commit 44eaf7b
Showing
1 changed file
with
36 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,36 @@ | ||
import java.io.*; | ||
|
||
// java program for left triangle | ||
public class GFG { | ||
// Function to demonstrate printing pattern | ||
public static void StarleftTriangle(int k) | ||
{ | ||
int a, b; | ||
|
||
// 1st loop | ||
for (a = 0; a < k; a++) { | ||
|
||
// nested 2nd loop | ||
for (b = 2 * (k - a); b >= 0; b--) { | ||
// printing spaces | ||
System.out.print(" "); | ||
} | ||
|
||
// nested 3rd loop | ||
for (b = 0; b <= a; b++) { | ||
// printing stars | ||
System.out.print("* "); | ||
} | ||
|
||
// end-line | ||
System.out.println(); | ||
} | ||
} | ||
|
||
// Driver Function | ||
public static void main(String args[]) | ||
{ | ||
int k = 5; | ||
StarleftTriangle(k); | ||
} | ||
} |