Java Program to Print Inverted Right Triangle Star Pattern

Write a Java Program to print an inverted right triangle star pattern using for loop. This example uses a nested for loop to iterate from top to bottom and display the output.

package ShapePrograms;

import java.util.Scanner;

public class InvertedRightTriangle1 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Inverted Right Triangle Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("Printing Inverted Right Triangle Star Pattern");
		
		for (int i = rows; i > 0; i-- ) 
		{
			for (int j = 0 ; j < i; j++ ) 
			{
				System.out.print("*");
			}
			System.out.println();
		}
	}
}
Java Program to Print Inverted Right Triangle Star Pattern 1

In this inverted right triangle star pattern program, we replaced for loops with while loops.

package ShapePrograms;

import java.util.Scanner;

public class InvertedRightTriangle2 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Inverted Right Triangle Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("-- Printing Inverted Right Triangle Star Pattern --");
		int j, i = rows; 
		while (i > 0) 
		{
			j = 0 ; 
			while (j < i) 
			{
				System.out.print("*");
				j++;
			}
			System.out.println();
			i--;
		}
	}
}
Enter Inverted Right Triangle Pattern Rows = 9
-- Printing Inverted Right Triangle Star Pattern --
*********
********
*******
******
*****
****
***
**
*

Java Program to Print Inverted Right Triangle Star Pattern using do while loop

package ShapePrograms;

import java.util.Scanner;

public class InvertedRightTriangle3 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Inverted Right Triangle Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.println("-- Printing Inverted Right Triangle Star Pattern --");
		int j, i = rows; 
		do
		{
			j = 0; 
			do
			{
				System.out.print("*");
			} while (++j < i);
			System.out.println();
		}while (--i > 0);
	}
}
Enter Inverted Right Triangle Pattern Rows = 13
-- Printing Inverted Right Triangle Star Pattern --
*************
************
***********
**********
*********
********
*******
******
*****
****
***
**
*

In this example, the InvertedRightTrianglePat function prints a given symbol’s inverted right triangle pattern.

package ShapePrograms;

import java.util.Scanner;

public class InvertedRightTriangle4 {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		
		System.out.print("Enter Inverted Right Triangle Pattern Rows = ");
		int rows = sc.nextInt();
		
		System.out.print("Enter Character for Inverted Right Triangle Pattern = ");
		char ch = sc.next().charAt(0);
		
		InvertedRightTrianglePat(rows, ch);
		
	}
	public static void InvertedRightTrianglePat(int rows, char ch) {
		for (int i = rows; i > 0; i-- ) 
		{
			for (int j = 0 ; j < i; j++ ) 
			{
				System.out.print(ch);
			}
			System.out.println();
		}
	}
}
Enter Inverted Right Triangle Pattern Rows = 15
Enter Character for Inverted Right Triangle Pattern = &
&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&
&&&&&&&&&&&&&
&&&&&&&&&&&&
&&&&&&&&&&&
&&&&&&&&&&
&&&&&&&&&
&&&&&&&&
&&&&&&&
&&&&&&
&&&&&
&&&&
&&&
&&
&