Java Program to Print Right Triangle Star Pattern
In this article, we will learn about printing Right Triangle Star Pattern.
Examples:
Input : n = 5 Output: * * * * * * * * * * * * * * *
Right Triangle Star Pattern:
Java
import java.io.*; // Java code to demonstrate right star triangle public class GeeksForGeeks { // Function to demonstrate printing pattern public static void StarRightTriangle( int n) { int a, b; // outer loop to handle number of rows // k in this case for (a = 0 ; a < n; a++) { // inner loop to handle number of columns // values changing acc. to outer loop for (b = 0 ; b <= a; b++) { // printing stars System.out.print( "* " ); } // end-line System.out.println(); } } // Driver Function public static void main(String args[]) { int k = 5 ; StarRightTriangle(k); } } |
Output
* * * * * * * * * * * * * * *
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.