//Java program to print increasing half triangle pattern.
import java.util.Scanner;
class IncreasingTriangle
{
static void increasingTriangle()
{
System.out.print("Enter the height of the triangle :");
Scanner sc = new Scanner(System.in);
int height = sc.nextInt();
//Nested for loops to print the two dimensional pattern.
for(int i = 0; i < height; i++)
{
for(int j = 1; j<= i+1; j++)
{
System.out.print(j);
}
//Introduce a new line.
System.out.println();
}
}
public static void main(String[] args)
{
increasingTriangle();
}
}
👆Java program to print increasing triangle pattern.
Output:
.png)
No comments:
Post a Comment