Reverse Triangle, E Always First in C#

What You’ll Learn
How to print a reverse triangle where every row begins with the same top letter (E in the 5-row example) and becomes shorter each line: EDCBA, EDCB, EDC, ED, E.
Compare program 7 (the first letter changes each row) and program 2 (different reverse-row growth rule).
⭐ Pattern Output
For 5 rows:
EDCBA
EDCB
EDC
ED
EComplete C# Program
Outer loop raises the stopping letter; inner loop always starts at E and counts down.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
for (char i = 'A'; i <= 'E'; i++)
{
for (char j = 'E'; j >= i; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop raises the floor
i runs from 'A' to 'E'. It sets how far down the inner loop should go on that row.
Inner loop always starts at E
j starts at 'E' on every row, so the first printed character is always E.
Shrinking tail
The condition j >= i makes the row shorter each time: when i is A, you print down to A; when i is E, you print only E.
Mixed directions
Outer i++ and inner j-- together control the clipping. Total work is still 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 = 'A'; i <= top; i++)
{
for (char j = top; j >= i; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Validate input with
int.TryParsebefore usingrows - Try lowercase using
'a'and'a' + rows - 1 - Compare with Program 7 (first letter changes each row)
- Add spaces between letters for readability
Avoid
- Using
j >= 'A'when you want shrinking rows (that would print full width every time) - Letting
rowsexceed 26 without handling letters beyond'Z' - Forgetting
Console.WriteLine()after each row
Key Takeaways
The inner loop always starts at the top letter, so the first character is fixed.
The outer loop only tightens the stopping point, shortening each row.
Mixed increment/decrement loops are common in pattern problems.
Complexity is O(n²) for n rows.
❓ Frequently Asked Questions
j to the top letter each time, so the first output is always E.Explore More C# Alphabet Patterns!
Fixing one corner and sliding loop bounds is a great way to invent new patterns.
If you changed the inner condition from j >= i to j >= 'A', every row would print the full EDCBA string—no shrinking.
12 people found this page helpful
