Increasing Start Letter Alphabet 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 each row starts one letter later but always ends at the same letter (E in the 5-row example). The widths go 5, 4, 3, 2, 1.

Contrast program 5 (rows restart at A) and program 3 (reverse starting letter but still ends at E).

⭐ Pattern Output

For 5 rows ending at 'E':

Output
ABCDE
BCDE
CDE
DE
E
1

Complete C# Program

Outer loop picks the starting letter (A to E). Inner loop prints from that start to the fixed end letter (E).

C#
using System;

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

🧠 How It Works

1

Outer loop chooses the start

i moves from 'A' to 'E'. That means each row starts one letter later.

Start moves right
2

Inner loop runs to a fixed end

j starts at i and goes up to 'E', so every row ends at the same letter.

Fixed end
3

New line

Console.WriteLine() ends each row.

Line break
=

Shrinking width

Row lengths sum to \(n + (n-1) + \cdots + 1 = \frac{n(n+1)}{2}\), so time complexity is O(n²).

2

Variation — User Input Version

Read the number of rows and compute the end 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 endChar = (char)('A' + rows - 1);
            for (char i = 'A'; i <= endChar; i++)
            {
                for (char j = i; j <= endChar; j++)
                {
                    Console.Write(j);
                }
                Console.WriteLine();
            }
        }
    }
}

💡 Tips for Enhancement

Try These

  • Validate input with int.TryParse before using rows
  • Try lowercase with 'a' and 'a' + rows - 1
  • Compare with Program 5 (same widths, different restart rule)
  • Print spaces between letters if you want a more spaced output

Avoid

  • Letting rows exceed 26 without handling letters beyond 'Z'
  • Using j-- here (that produces a different pattern, like program 4)
  • Forgetting Console.WriteLine() after each row

Key Takeaways

1

The outer loop controls the row’s starting letter.

2

The inner loop prints from the start letter up to a fixed end letter.

3

Row lengths shrink by one each time.

4

Complexity is O(n²) for n rows.

❓ Frequently Asked Questions

Because the inner loop always stops at the same end letter ('E'), so the last printed character is fixed.
That is Program 5, where each row starts at A and the end letter shrinks each time.
O(n²) for n rows.

Explore More C# Alphabet Patterns!

Changing only one loop bound can transform the entire output.

All Alphabet Patterns →
Did you know?

The right edge stays fixed because the inner loop always runs to the same end letter—only the starting bound changes.

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