Reverse Order Alphabet Triangle in C#

What You’ll Learn
How to print a right-angled triangle where the first character of each row moves forward (A, B, C, D, E), but each row prints letters in reverse order down to A: A, BA, CBA, DCBA, EDCBA.
Compare with program 1 (forward along each row) and program 3 (reverse starting letter, forward along row).
⭐ Pattern Output
For 5 rows:
A
BA
CBA
DCBA
EDCBAComplete C# Program
Outer loop picks the highest letter on each row; inner loop prints from that letter down to 'A'.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
for (char i = 'A'; i <= 'E'; i++)
{
for (char j = i; j >= 'A'; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop (rows)
i runs from 'A' to 'E'. Row length grows because later rows start at a higher letter.
Inner loop (descending letters)
For each row, j starts at i and counts down to 'A'. Printing j produces BA, CBA, DCBA, and so on.
New line
Console.WriteLine() ends the current row and moves to the next line.
Reverse-order triangle
Total printed characters are 1+2+…+n, so time complexity is O(n²).
Variation — User Input Version
Read the number of rows and loop i from 'A' to '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());
for (char i = 'A'; i < 'A' + rows; i++)
{
for (char j = i; j >= 'A'; j--)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Validate input with
int.TryParsebefore usingrows - Print lowercase by starting from
'a'instead of'A' - Compare with Program 1 (forward along the row)
- Right-align the output by printing leading spaces
Avoid
- Using
j++in the inner loop (that would print forward, not BA/CBA) - Letting
'A' + rows - 1go past'Z'without handling it - Forgetting
Console.WriteLine()after each row
Key Takeaways
The outer loop increases the row’s starting (highest) letter: A, B, C, …
The inner loop counts down from i to 'A' to print letters in reverse order.
Every row ends at 'A', so the right edge is vertical.
Complexity is O(n²) for n rows.
❓ Frequently Asked Questions
j reaches 'A', so the last printed character is A for every row.'A' up to the row’s end letter.Explore More C# Alphabet Patterns!
Small changes in loop direction completely change the output—keep experimenting.
This pattern’s left edge grows A, B, C, … while the right edge stays A. It’s a neat example of how loop bounds shape the output.
12 people found this page helpful
