Reverse Right-Angled Triangle Alphabet Pattern in C#

What You’ll Learn
How to print a reverse alphabet right-angled triangle in C#: each row has one more character than the previous row, and letters go from 'E' down to 'A' (for five rows) using nested for loops.
The output is E, ED, EDC, EDCB, EDCBA—same geometry as program 1, but descending along the alphabet on each row.
⭐ Pattern Output
For 5 rows:
E
ED
EDC
EDCB
EDCBAComplete C# Program
Fixed five rows: outer loop sets the last letter for each row (E, D, C, B, A) and the inner loop prints from 'E' down to that letter.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
for (char i = 'E'; i >= 'A'; i--)
{
for (char j = 'E'; j >= i; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop (rows)
The outer loop runs i from 'E' down to 'A'. Each value represents the last letter printed on that row.
Inner loop (descending letters)
For each row, the inner loop starts at 'E' and prints down to i using Console.Write(j). That yields E, then ED, then EDC, and so on.
New line
Console.WriteLine() ends the current row and moves to the next line.
Reverse letter triangle
You print 1+2+…+n letters in total, so time complexity is O(n²) for n rows.
Variation — User Input Version
Read the number of rows and compute the top letter as 'A' + rows - 1:
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
char top = (char)('A' + rows - 1);
for (char i = top; i >= 'A'; i--)
{
for (char j = top; j >= i; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Use
int.TryParseto validate input before computingtop - Print lowercase by using
'a'as the base instead of'A' - Add spaces between letters for readability
- Compare with Program 1 for the forward triangle
Avoid
- Forgetting that the pattern uses
j >= iwithj--for descending output - Letting
rowsexceed 26 without handling letters beyond'Z' - Skipping
Console.WriteLine()after each row
Key Takeaways
Row k prints k letters, and letters run from the top letter down to a row-specific end letter.
Use top = (char)('A' + rows - 1) to generalize the pattern for any row count.
Complexity is O(n²) for n rows.
This is a mirror of Program 1: only the letter direction changes.
❓ Frequently Asked Questions
top (E in the fixed example). Only the end letter changes with the outer-loop bound, so the triangle grows by one character each row.'A' and print to the current end letter.Explore More C# Alphabet Patterns!
Reverse and mixed letter patterns are great practice for loop bounds and character arithmetic.
In C#, decrementing a char works naturally: 'E' - 1 becomes 'D'. That’s why counting down with j-- prints letters in reverse order.
12 people found this page helpful
