Increasing Start Letter Alphabet Triangle in C#

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':
ABCDE
BCDE
CDE
DE
EComplete C# Program
Outer loop picks the starting letter (A to E). Inner loop prints from that start to the fixed end letter (E).
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
Outer loop chooses the start
i moves from 'A' to 'E'. That means each row starts one letter later.
Inner loop runs to a fixed end
j starts at i and goes up to 'E', so every row ends at the same letter.
New line
Console.WriteLine() ends each row.
Shrinking width
Row lengths sum to \(n + (n-1) + \cdots + 1 = \frac{n(n+1)}{2}\), so time complexity is O(n²).
Variation — User Input Version
Read the number of rows and compute the end letter as 'A' + rows - 1:
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.TryParsebefore usingrows - 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
rowsexceed 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
The outer loop controls the row’s starting letter.
The inner loop prints from the start letter up to a fixed end letter.
Row lengths shrink by one each time.
Complexity is O(n²) for n rows.
❓ Frequently Asked Questions
'E'), so the last printed character is fixed.Explore More C# Alphabet Patterns!
Changing only one loop bound can transform the entire output.
The right edge stays fixed because the inner loop always runs to the same end letter—only the starting bound changes.
12 people found this page helpful
