Back to: C#.NET Programs and Algorithms

**Mirrored Right Angle Triangle Star Pattern Program in C#**

In this article, I am going to discuss **Mirrored Right Angle Triangle Star Pattern Program in C#** with Examples. Please read our previous article where we discussed discuss **Right Triangle Star Pattern Program in C#**. Let us understand this. Please have a look at the below image which shows the Mirrored Right Angle Triangle Star Pattern.

**Understanding the Mirrored Right Angle Triangle Star Pattern**

If we want to create Mirrored Right Angle Triangle Star Pattern with four rows, then

- In the first row, we have 3 blank spaces and one star at the end.
- In the second row, we have 2 blank spaces and two stars at the end.
- In the third row, we have 1 blank space and three stars at the end.
- In the fourth row, we have 0 blank spaces and 4 stars at the end.

- From the above pattern, it is clear that at each row number of stars is increasing +1 at each row.
- For example, the 1st row has 1 star, the 2nd row has 2 stars and the 3rd row has 3 stars, and so on.
- From the above pattern, it is clear that at each row number of blank spaces are decreasing –1 at each row. For example, the 1st row has 4 spaces, the 2nd row has 3 spaces, the 3rd row has 2 spaces, and so on.

**How to Implement the Mirrored Right Angle Triangle Star Pattern in C#?**

To solve the above pattern,

- We are going to use three for loops. One outer for loop and two inner for loops.
- The outer for loop will be used to handle the rows one by one and the two inner for loops will be used to handle the columns one by one.
- From the above explanation, it is clear that the number of stars in each row is equal to the current row.
- 1st row has 1 star, 2nd row has 2 stars, and so on.
- The inner loop will be used to print the stars according to row and the outer loop job is to go on a new line after printing the current row stars.

**C# Program to Print Mirrored Right Angle Triangle Star Pattern**

The following C# Program will allow the user to input the number of rows and then print the mirrored right angle triangle star pattern on the console.

using System; public class MirroredRightAngleTriangleStar { public static void Main() { Console.WriteLine("Enter number of Rows :"); int rows = Convert.ToInt32(Console.ReadLine()); for (int i = 1; i <= rows; i++) { //rows - i //let rows = 5 /* first row (5-1) = 4 spaces * second row (5-2) = 3 spaces * third row (5-3) = 2 spaces * and so on */ //calculate blank space for each row one by one for (int j = rows - i; j >= 1; j--) { Console.Write(" "); } //calculate no. of stars in each row for (int k = 1; k <= i; k++) { Console.Write("*"); } Console.WriteLine("\n"); } Console.ReadLine(); } }

**Output:**

In the next article, I am going to discuss **Downward Right-angle Triangle Star Pattern Program in C#** with Examples. Here, in this article, I try to explain **Mirrored Right Angle Triangle Star Pattern Program in C# **with Examples and I hope you enjoy this article.

**About the Author: Pranaya Rout**

Pranaya Rout has published more than 3,000 articles in his 11-year career. Pranaya Rout has very good experience with Microsoft Technologies, Including C#, VB, ASP.NET MVC, ASP.NET Web API, EF, EF Core, ADO.NET, LINQ, SQL Server, MYSQL, Oracle, ASP.NET Core, Cloud Computing, Microservices, Design Patterns and still learning new technologies.