In this “Print Inverted Right Triangle Pattern” – We have written Java programs to print/draw Inverted Right Triangle pattern by using different types of Java loops and you can execute and try these Java program through your IDE. This is most [100+] Frequently Asked Java Program on beginner level to check you Java Programming skills and Concept.
Inverted Right Triangle Pattern Example

This post covers following ways to print Inverted Right Triangle Pattern:
- Print Inverted Right Triangle Java Program: Using for Loop
- Print Inverted Right Triangle Java Program: Using While Loop
- Print Inverted Right Triangle Java Program: Using Do-While Loop
Inverted Right Triangle Pattern Java Program: For Loop
This Inverted Right Triangle Java Program is following the below logic:
- Run the outer for loop till entered size (int i = n; i > 0; i–) to print symbol. Where the n represent the size of triangle.
- Every in inner for loop (int j = 0; j < i; j++) this size will get reduce by one do print symbol and continue till outer loop is not completed.
package _1_patterns.Inverted_Right_Triangle;
import java.util.Scanner;
public class InvertedRightTrianglePatternForLoop {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Pattern Size : ");
int size = sc.nextInt();
System.out.print("Enter Symbol : ");
char symbol = sc.next().charAt(0);
drawInvertedRightTrianglePattern(size, symbol);
// Close Scanner
sc.close();
}
private static void drawInvertedRightTrianglePattern(int n, char c) {
for (int i = n; i > 0; i--) {
for (int j = 0; j < i; j++) {
System.out.print(c);
}
System.out.println();
}
}
}
Output
Enter Pattern Size : 5 Enter Symbol : * ***** **** *** ** *
Inverted Right Triangle Pattern Java Program: While Loop
This Inverted Right Triangle Java Program is following the below logic:
- Run the outer while loop till entered size (i > 0) to print symbol. Where the n represent the size of triangle.
- Every in inner while loop (j++ < i) this size will get reduce by one do print symbol and continue till outer loop is not completed.
package _1_patterns.Inverted_Right_Triangle;
import java.util.Scanner;
public class InvertedRightTrianglePatternForLoop {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Pattern Size : ");
int size = sc.nextInt();
System.out.print("Enter Symbol : ");
char symbol = sc.next().charAt(0);
drawInvertedRightTrianglePattern(size, symbol);
// Close Scanner
sc.close();
}
private static void drawInvertedRightTrianglePattern(int n, char c) {
int i = n, j;
while (i > 0) {
j = 0;
while (j++ < i) {
System.out.print(c);
}
System.out.println();
i--;
}
}
}
Output
Enter Pattern Size : 7 Enter Symbol : # ####### ###### ##### #### ### ## #
Inverted Right Triangle Pattern Java Program: Do-While Loop
This Inverted Right Triangle Java Program is following the below logic:
- Run the outer do-while loop till entered size (–i > 0) to print symbol. Where the n represent the size of triangle.
- Every in inner do-while loop (++j < i) this size will get reduce by one do print symbol and continue till outer loop is not completed.
package _1_patterns.Inverted_Right_Triangle;
import java.util.Scanner;
public class InvertedRightTrianglePatternForLoop {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Pattern Size : ");
int size = sc.nextInt();
System.out.print("Enter Symbol : ");
char symbol = sc.next().charAt(0);
drawInvertedRightTrianglePattern(size, symbol);
// Close Scanner
sc.close();
}
private static void drawInvertedRightTrianglePattern(int n, char c) {
int i = n;
do {
int j = 0;
do {
System.out.print(c);
} while (++j < i);
System.out.println();
} while (--i > 0);
}
}
Output
Enter Pattern Size : 8 Enter Symbol : $ $$$$$$$$ $$$$$$$ $$$$$$ $$$$$ $$$$ $$$ $$ $
Related Posts
Your Feedback Motivate Us
If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.
Happy Learning !!!
You must log in to post a comment.