This is a left align triangle and it creates based on a user input.

Program Code :


import java.util.Scanner;
public class Triangle1 {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
System.out.print("Enter the number of star = ");
int n=scn.nextInt();
for (int i = 0; i < n; i++) {
for (int j = 0; j < i; j++) {
System.out.print("*");
}
System.out.println("");
}
}
}

Output : 

Enter the number of star = 7
*
**
***
****
*****
******
*******


 
Top