Reverse Alphabet Decreasing Triangle in C#

Beginner
⏱️ 5 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Nested Loops

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:

Output
EDCBA
DCBA
CBA
BA
A
1

Complete C# Program

Outer loop chooses the starting letter (E down to A). Inner loop prints from that start down to A.

C#
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

1

Outer loop sets the row start

i runs from 'E' down to 'A'. That is the first letter on each row.

Start moves left
2

Inner loop prints down to A

j runs from i down to 'A', so each row prints reverse alphabetical order.

Descending letters
3

New line

Console.WriteLine() ends each row.

Line break
=

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²).

2

Variation — User Input Version

Read the number of rows and compute the top letter as 'A' + rows - 1:

C#
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.TryParse before using rows
  • 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 rows exceed 26 without handling letters beyond 'Z'
  • Forgetting Console.WriteLine() after each row

Key Takeaways

1

Outer loop lowers the starting letter each row.

2

Inner loop prints backward to 'A' on each row.

3

Row lengths shrink by one each time.

4

Complexity is O(n²) for n rows.

❓ Frequently Asked Questions

Because the inner loop condition includes j == 'A', so the final character printed on each row is always A.
Program 8 always starts each row at E and shortens the tail. Program 7 changes the first letter each row (E, then D, then C...).
O(n²) for n rows.

Explore More C# Alphabet Patterns!

Reverse loops are just as useful as forward loops for pattern printing.

All Alphabet Patterns →
Did you know?

This pattern mirrors Program 6: there the right edge was fixed at E; here the right edge is fixed at A.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful