Repeating-Letter Alphabet Triangle in C#

What You’ll Learn
Row 1 is one A, row 2 is two Bs, row 3 three Cs, and so on: A, BB, CCC, DDDD, EEEEE.
This is a great contrast to program 1, where letters change inside each row (A, AB, ABC...). Here, the row letter stays the same and only the count grows.
⭐ Pattern Output
For 5 rows:
A
BB
CCC
DDDD
EEEEEComplete C# Program
The inner loop runs the correct number of times, but always prints i (the row 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(i);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop selects the row letter
i runs from 'A' to 'E'. That’s the character printed on the row.
Inner loop controls the repeat count
j runs from 'A' to i, so it executes 1, 2, 3, 4, then 5 times.
Print i, not j
Printing i keeps the whole row the same letter. Printing j would change letters across the row (a different pattern).
Same triangle shape
Total prints are 1+2+…+n for n rows, so time complexity is O(n²).
Variation — User Input Version
For a dynamic row count, compute the row letter from the row number. Keep rows within 26 if you want only A–Z.
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 (int row = 1; row <= rows; row++)
{
char ch = (char)('A' + row - 1);
for (int col = 1; col <= row; col++)
{
Console.Write(ch);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Use lowercase by replacing
'A'with'a' - Add a space after each letter to make the triangle wider and easier to read
- Compare with Program 1 (letters change across the row)
- Cap
rowsat 26 if you want to stay in A–Z
Avoid
- Printing
jinstead of the row letter if you want repeats - Incrementing the character inside the inner loop (that changes the pattern)
- Allowing very large
rowswithout deciding what to do after'Z'
Key Takeaways
The row letter is chosen by the outer loop.
The inner loop only controls the number of repeats.
Printing i (not j) is what makes the row uniform.
Time complexity is O(n²) for n rows.
❓ Frequently Asked Questions
ch = (char)('A' + row - 1).Explore More C# Alphabet Patterns!
A one-line change inside the inner loop can switch between “repeating letters” and “stepping letters” patterns.
Instead of carrying a variable like ch++ across rows, you can compute the row character directly from the row number using (char)('A' + row - 1).
12 people found this page helpful
