Right-Angled Triangle Alphabet Pattern in C#

What You’ll Learn
How to print an alphabet right-angled triangle in C#: each row starts at 'A' and extends one letter further than the previous row, using nested for loops and Console.Write.
With five rows, the output is A, AB, ABC, ABCD, and ABCDE—the same triangle shape as a star pattern, but with letters.
⭐ Pattern Output
For 5 rows, the pattern looks like this:
A
AB
ABC
ABCD
ABCDEComplete C# Program
Fixed five rows: outer loop picks the last letter on each row ('A' to 'E'); inner loop prints from 'A' through that letter.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
for (char i = 'A'; i <= 'E'; i++)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop (rows)
The outer loop runs i from 'A' through 'E'. Each value represents the last letter to print on that row.
Inner loop (letters)
For each row, the inner loop starts from 'A' and prints up to i using Console.Write(j).
New line
After printing one row, Console.WriteLine() moves output to the next line so the next row starts cleanly.
Right-angled letter triangle
You print 1+2+…+n letters in total, so time complexity is O(n²) for n rows.
Variation — User Input Version
Read the number of rows and print up to the corresponding last letter:
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
for (char i = 'A'; i < 'A' + rows; i++)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Validate input with
int.TryParsebefore usingrows - Print lowercase by starting from
'a'instead of'A' - Add spaces between letters for readability
- Try reverse order patterns next (e.g., CBA, DCBA)
Avoid
- Using a negative row count (guard against invalid input)
- Forgetting
Console.WriteLine()after each row - Letting
'A' + rowsgo past'Z'without handling wrapping
Key Takeaways
Each row starts at 'A' and grows by one letter.
Nested loops map naturally to row/column pattern output.
Complexity is O(n²) for n rows.
You can generalize the last letter with 'A' + rows - 1.
❓ Frequently Asked Questions
'A' and only the upper bound changes with the outer-loop letter.char ch that you increment across prints and don’t reset it after each row.Explore More C# Alphabet Patterns!
Letter triangles and pyramids build on the same nested-loop idea you used here.
In C#, char values can be incremented: 'A' + 1 becomes 'B'. That’s why looping from 'A' to 'A' + rows - 1 works naturally for this pattern.
12 people found this page helpful
