Reverse Alphabet Decreasing Triangle in C#

What You’ll Learn
How to print a triangle where the first row is the full reverse run from 'E' down to 'A', and each next row becomes shorter: EDCBA, DCBA, CBA, BA, A.
This is the reverse-direction companion to program 6 (ABCDE, BCDE, … ending at E).
⭐ Pattern Output
For 5 rows:
EDCBA
DCBA
CBA
BA
AComplete C# Program
Outer loop chooses the starting letter (E down to A). Inner loop prints from that start down to A.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
for (char i = 'E'; i >= 'A'; i--)
{
for (char j = i; j >= 'A'; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop sets the row start
i runs from 'E' down to 'A'. That is the first letter on each row.
Inner loop prints down to A
j runs from i down to 'A', so each row prints reverse alphabetical order.
New line
Console.WriteLine() ends each row.
Shrinking rows
Total printed characters are 5+4+3+2+1 for 5 rows. In general it is \(n(n+1)/2\), so time complexity is O(n²).
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 = i; j >= 'A'; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Validate input with
int.TryParsebefore usingrows - Try lowercase by using
'a'instead of'A' - Compare with Program 6 for forward slices ending at E
- Add spaces between characters if you want clearer output
Avoid
- Using
j++in the inner loop if you want reverse order - Letting
rowsexceed 26 without handling letters beyond'Z' - Forgetting
Console.WriteLine()after each row
Key Takeaways
Outer loop lowers the starting letter each row.
Inner loop prints backward to 'A' on each row.
Row lengths shrink by one each time.
Complexity is O(n²) for n rows.
❓ Frequently Asked Questions
j == 'A', so the final character printed on each row is always A.Explore More C# Alphabet Patterns!
Reverse loops are just as useful as forward loops for pattern printing.
This pattern mirrors Program 6: there the right edge was fixed at E; here the right edge is fixed at A.
12 people found this page helpful
