Inverted Forward Repeating Alphabet Triangle in C#

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

What You’ll Learn

Row width shrinks from five to one, but the letter moves forward each row: AAAAA, BBBB, CCC, DD, E.

Compare program 11 (same shape, letters step down from E) and program 9 (width grows with forward letters).

⭐ Pattern Output

For 5 rows:

Output
AAAAA
BBBB
CCC
DD
E
1

Complete C# Program

Outer loop selects the row letter (A up to E). Inner loop counts down from E 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 = 'A'; i <= 'E'; i++)
            {
                for (char j = 'E'; j >= i; j--)
                {
                    Console.Write(i);
                }
                Console.WriteLine();
            }
        }
    }
}

🧠 How It Works

1

Outer loop: choose the letter

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

A → E
2

Inner loop: control the width

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

5..1
3

Print the row letter

Inside the inner loop, print i to keep the row uniform: AAAAA, then BBBB, 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 while letters go forward.

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

💡 Tips for Enhancement

Try These

  • Compare with Program 11 (same inverted shape, letters step down)
  • 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

Row widths shrink from 5 to 1 (inverted triangle).

2

Letters move forward from A to E.

3

Print the outer-loop letter to repeat the row character.

4

Complexity is O(n²) for n rows.

❓ Frequently Asked Questions

Program 11 prints EEEEE, DDDD, ... (letters step down). Program 12 prints AAAAA, BBBB, ... (letters step up) with the same inverted widths.
Because the inner loop runs from the fixed top letter down to the current i. As i increases, the loop has fewer iterations.
O(n²) for n rows.

Explore More C# Alphabet Patterns!

Inverted patterns often come from flipping which variable sets the inner loop limit.

All Alphabet Patterns →
Did you know?

This pattern is the forward-letter counterpart of program 11: same inverted triangle widths, but the letter direction is A→E instead of E→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