87. JAVA Program to Print Number triangle.
How does this program work?
- This program is used to print Number Triangle using Java.
Here is the code
//To print Triangle Pattern
import java.util.Scanner;public class triangle
{
public static void main(String args[] )
{
int i,j,rows;
System.out.println("Enter the number of rows");
Scanner obj =new Scanner(System.in );
rows=obj.nextInt();
for(i=1;i<=rows;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println(" ");
}
}
}