Inverted Repeating-Letter Alphabet Triangle in C#

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

What You’ll Learn

First row: five Es. Each following row is one character shorter and uses the next letter down: EEEEE, DDDD, CCC, BB, A.

Compare with program 10 (width grows 1..5 while letters go E→A) and program 9 (width grows and letters go A→E).

⭐ Pattern Output

For 5 rows:

Output
EEEEE
DDDD
CCC
BB
A
1

Complete C# Program

Outer loop selects the row letter (E down to A). Inner loop runs from A up to that letter, which produces widths 5..1 while printing the 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 = 'A'; j <= i; j++)
                {
                    Console.Write(i);
                }
                Console.WriteLine();
            }
        }
    }
}

🧠 How It Works

1

Outer loop: choose the letter

i runs from 'E' down to 'A'. That becomes the row character.

E → A
2

Inner loop: control the width

j runs from 'A' to i. That gives 5 iterations for E, 4 for D, ... 1 for A.

5..1
3

Print the row letter

Inside the inner loop, print i to keep the row uniform: EEEEE, then DDDD, and so on.

Repeat
=

Total work

You still print 5+4+3+2+1 characters for 5 rows. In general, it is \(n(n+1)/2\) so complexity is O(n²).

2

Variation — User Input Version

Generalize by choosing the top letter as 'A' + rows - 1, then print widths from rows down to 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 ch = top; ch >= 'A'; ch--)
            {
                int repeat = ch - 'A' + 1;
                for (int k = 1; k <= repeat; k++)
                {
                    Console.Write(ch);
                }
                Console.WriteLine();
            }
        }
    }
}

💡 Tips for Enhancement

Try These

  • Compare with Program 10 (same letters, width grows instead of shrinking)
  • Use lowercase by switching to 'a' and 'a' + rows - 1
  • Add a space after each character if you want a wider shape
  • Validate input with int.TryParse

Avoid

  • Printing the inner-loop variable if you want repeating letters
  • Letting rows exceed 26 without handling letters beyond 'Z'
  • Changing the letter inside the inner loop (that creates different patterns)

Key Takeaways

1

First row is widest and repeats the top letter.

2

Each next row is shorter and uses the next letter down.

3

Print the outer-loop letter inside the inner loop for repeats.

4

Complexity is O(n²) for n rows.

❓ Frequently Asked Questions

Program 10 prints widths 1..5 (E, DD, CCC, ...). Program 11 prints widths 5..1 (EEEEE, DDDD, ...). Both use repeating letters per row.
Because the inner loop stops at j <= i. Smaller i means fewer iterations, so fewer characters are printed.
O(n²) for n rows.

Explore More C# Alphabet Patterns!

Inverted patterns usually come from flipping loop bounds (count down instead of up, or stop earlier).

All Alphabet Patterns →
Did you know?

This is the inverted version of the repeating-letter idea: instead of growing from 1 to 5, the row widths shrink from 5 to 1, while the row letter steps downward.

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