Reverse Repeating-Letter Alphabet Triangle in C#

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

What You’ll Learn

Same repeating idea as program 9, but letters run E → D → C → B → A while row widths still grow 1, 2, 3, 4, 5.

The simplest trick is to keep the row letter in the outer loop and print it repeatedly inside the inner loop.

⭐ Pattern Output

For 5 rows:

Output
E
DD
CCC
BBBB
AAAAA
1

Complete C# Program

Outer loop selects the row letter (E down to A). Inner loop runs the correct number of times and prints that same row letter.

C#
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(i);
                }
                Console.WriteLine();
            }
        }
    }
}

🧠 How It Works

1

Outer loop selects row letter

i runs from 'E' down to 'A'. That is the character printed on the row.

E → A
2

Inner loop controls repeat count

j runs from 'E' down to i, so it executes 1 time for E, 2 times for D, and so on.

1..5 repeats
3

Print i, not j

Printing i makes the row uniform (DD, CCC, ...). Printing j would step letters along the row instead.

Key idea
=

Same triangle shape as program 9

Total prints are 1+2+…+n for n rows, so time complexity is O(n²).

2

Variation — User Input Version

Generalize by computing the top letter as 'A' + rows - 1, then count down.

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 ch = top; ch >= 'A'; ch--)
            {
                int repeat = (top - ch) + 1;
                for (int k = 1; k <= repeat; k++)
                {
                    Console.Write(ch);
                }
                Console.WriteLine();
            }
        }
    }
}

💡 Tips for Enhancement

Try These

  • Compare with Program 9 (same repeats, forward letters)
  • Try lowercase by using 'a' and 'a' + rows - 1
  • Add spaces to create a wider triangle
  • Validate input with int.TryParse

Avoid

  • Printing the inner-loop variable if you want rows to repeat the same character
  • Letting rows exceed 26 without deciding what to do after 'Z'
  • Incrementing the character inside the inner loop (that changes the output)

Key Takeaways

1

Outer loop chooses the letter for the row (E down to A).

2

Inner loop only decides how many times to print.

3

Printing i is what makes each row a repeated-letter row.

4

Time complexity is O(n²) for n rows.

❓ Frequently Asked Questions

Program 9 uses A, BB, CCC, ... (forward letters). Program 10 uses E, DD, CCC, ... (reverse letters) with the same increasing repeat counts.
Yes. If top is the highest letter, you can use ch = (char)(top - (row - 1)).
O(n²) for n rows.

Explore More C# Alphabet Patterns!

Once you understand where to update the character (outer vs inner loop), you can build many variations quickly.

All Alphabet Patterns →
Did you know?

Program 9 and 10 differ only in the outer letter direction: increasing (A to E) vs decreasing (E to A). The inner loop still prints the same letter repeatedly.

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