Sequential Decreasing Alphabet Triangle in C#

What You’ll Learn
This pattern prints a continuous alphabet sequence across rows, but each next row prints one fewer letter than the previous.
We keep a running counter (k++) so the sequence goes A through O for five rows.
⭐ Pattern Output
Output for 5 rows:
A B C D E
F G H I
J K L
M N
OComplete C# Program (Fixed 5 Rows)
One counter k supplies letters; the inner loop decides how many times to print it in each row.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
char k = 'A';
for (int i = 1; i <= 5; i++)
{
for (int j = 5; j >= i; j--)
Console.Write("{0,2} ", k++);
Console.WriteLine();
}
}
}
}🧠 How It Works
k is a running alphabet counter
We start at 'A' and increment only when printing a letter.
Inner loop length decreases
The inner loop runs 5, then 4, then 3, etc. as i increases.
Formatting keeps spacing readable
{0,2} prints each letter in a 2-column field. A trailing space separates letters.
One continuous sequence
Total letters printed over n rows is \(n(n+1)/2\), so work grows as O(n²).
Variation — User Input Rows
Let the user choose rows. (If rows are large, letters will go beyond Z unless you add wrapping.)
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter number of rows (like 5): ");
int n = int.Parse(Console.ReadLine());
if (n < 1) return;
char k = 'A';
for (int i = 1; i <= n; i++)
{
for (int j = n; j >= i; j--)
Console.Write("{0,2} ", k++);
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Wrap letters after
Zusing modulo arithmetic - Remove the trailing space if you want tighter output
- Use lowercase by starting
kat'a' - Compare with Program 22 (right-aligned sequential pyramid)
Avoid
- Resetting
kinside the outer loop (sequence won’t be continuous) - Printing in a proportional font (alignment looks uneven)
- Letting
nget too large without a wrap rule for letters
Key Takeaways
Keep k outside the outer loop for a continuous stream.
Row lengths decrease by one each row.
{0,2} helps keep consistent spacing.
Total printed letters over n rows is \(n(n+1)/2\).
❓ Frequently Asked Questions
k each row, every row would start at A again.12 people found this page helpful
