Decreasing Triangle Pattern Program
- Categories Java
Write a java pattern programs triangle to print pattern as shown where no of rows are given by user.
Enter the number of rows: 5
* * * * *
* * * *
* * *
* *
*
import java.util.Scanner;
public class DecreasingTriangle
{
public static void main (String args[])
{
Scanner scan = new Scanner(System.in);
System.out.print("Enter Number of Rows : ");
int n = scan.nextInt();
for (int i = 1; i<=n ; i++) {
for (int j = i; j<=n; j++) {
System.out.print(“* ”);
}
System.out.println();
}
}
}
You may also like
Single Linked List Programs in Java
28 August, 2021
Implementing Stack using Array in Java
28 August, 2021
Constructor Programs
3 July, 2021