Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Create LeftTriangle.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaibhavpan02 authored Oct 30, 2022
1 parent ecde276 commit 44eaf7b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions LeftTriangle.java
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);
}
}

0 comments on commit 44eaf7b

Please sign in to comment.