Triangle with Reverse Starting Letter in C#

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

What You’ll Learn

This pattern mixes ideas from program 1 and program 2: each row is longer than the last, the first letter moves backward (E, D, C, ...), but along the row letters still run forward (D then E, C then D then E, ...).

With five rows, you get E, DE, CDE, BCDE, ABCDE.

⭐ Pattern Output

For 5 rows:

Output
E
DE
CDE
BCDE
ABCDE
1

Complete C# Program

Outer loop chooses the first letter on the row; inner loop prints forward up to 'E'.

C#
using System;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            for (char i = 'E'; i >= 'A'; i--)
            {
                for (char j = i; j <= 'E'; j++)
                {
                    Console.Write(j);
                }
                Console.WriteLine();
            }
        }
    }
}

🧠 How It Works

1

Outer loop: move the start

i runs from 'E' down to 'A'. That makes each row start one letter earlier.

Row start
2

Inner loop: print forward

For each row, j runs from i up to 'E'. So row i prints i, i+1, ..., 'E'.

Letters
3

New line

Console.WriteLine() ends the row and moves to the next line.

Line break
=

Reverse start, forward run

Total printed characters are 1+2+…+n, so time complexity is O(n²).

2

Variation — User Input Version

Read the number of rows and compute the right-edge letter top 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 <= top; j++)
                {
                    Console.Write(j);
                }
                Console.WriteLine();
            }
        }
    }
}

💡 Tips for Enhancement

Try These

  • Validate input with int.TryParse before computing top
  • Switch top to a fixed letter (like 'Z') to shift the whole pattern
  • Use lowercase by starting from 'a' instead of 'A'
  • Compare with Program 2 (descending along each row)

Avoid

  • Confusing this with the reverse-row pattern (that one uses j--)
  • Letting rows exceed 26 without handling characters beyond 'Z'
  • Forgetting Console.WriteLine() after each row

Key Takeaways

1

The row’s first letter moves backward (E, D, C, …), but letters on the row move forward.

2

Using j from i to top keeps the right edge fixed at top.

3

Complexity is O(n²) for n rows.

4

This is different from Program 2 because the inner loop increments (j++), not decrements.

❓ Frequently Asked Questions

Because the inner loop always stops at top (E in the fixed example), so the last printed character is always that same letter.
That is Program 2, where the inner loop counts downward with j--.
O(n²) for n rows because you print 1+2+…+n characters.

Explore More C# Alphabet Patterns!

Mix forward and reverse loops to build new letter patterns quickly.

All Alphabet Patterns →
Did you know?

If the row starts at top - k and prints \(k+1\) letters forward, the last letter is always top. That’s why the right edge stays aligned.

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