Sequential Decreasing Alphabet Triangle in C#

Beginner
⏱️ 7 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Nested Loops

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:

Output
A B C D E
F G H I
J K L
M N
O
1

Complete C# Program (Fixed 5 Rows)

One counter k supplies letters; the inner loop decides how many times to print it in each row.

C#
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

1

k is a running alphabet counter

We start at 'A' and increment only when printing a letter.

Stream
2

Inner loop length decreases

The inner loop runs 5, then 4, then 3, etc. as i increases.

Shrink
3

Formatting keeps spacing readable

{0,2} prints each letter in a 2-column field. A trailing space separates letters.

Align
=

One continuous sequence

Total letters printed over n rows is \(n(n+1)/2\), so work grows as O(n²).

2

Variation — User Input Rows

Let the user choose rows. (If rows are large, letters will go beyond Z unless you add wrapping.)

C#
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 Z using modulo arithmetic
  • Remove the trailing space if you want tighter output
  • Use lowercase by starting k at 'a'
  • Compare with Program 22 (right-aligned sequential pyramid)

Avoid

  • Resetting k inside the outer loop (sequence won’t be continuous)
  • Printing in a proportional font (alignment looks uneven)
  • Letting n get too large without a wrap rule for letters

Key Takeaways

1

Keep k outside the outer loop for a continuous stream.

2

Row lengths decrease by one each row.

3

{0,2} helps keep consistent spacing.

4

Total printed letters over n rows is \(n(n+1)/2\).

❓ Frequently Asked Questions

So the sequence continues across rows (A, B, C, ...). If you reset k each row, every row would start at A again.
Build a row string and trim it, or print a space only between letters (not after the last letter in the row).
O(n²) because the total number of printed cells grows quadratically with the number of rows.

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