C# Repeating Alphabet Triangle Pattern

Beginner
6 min read
Updated: Sep 2026
3 programs
Live preview

What Is This Pattern?

A repeating alphabet triangle grows by one character each row, but every character on that row is the same letter — the letter advances with the row.

Remember
Rule: for letter i from A to last,
      print i with growing width 1, 2, 3, …

A
BB
CCC
DDDD
EEEEE     ← 5 rows

Unlike Program 1 (A, AB, ABC), letters do not step across the row — you print the outer loop letter inside the inner loop. The reverse twin is Program 10 (E, DD, CCC, …).

How to Solve It

Two ways to emit the same shape — start with nested char loops, then optionally shorten with new string.

MethodIdeaBest for
Nested char loopsOuter = letter; inner = growing width; print outer letterLearning, interviews, exams
new string(ch, row)Build a whole repeated-letter row in one callShorter demos once loops click

Pseudocode

Pseudocode
for i from 'A' to lastLetter:
    for j from 'A' to i:
        print i (no newline)
    print newline

Cheat sheet

GoalPattern
Advance letterfor (char i = 'A'; i <= last; i++)
Grow widthfor (char j = 'A'; j <= i; j++)
Uniform rowConsole.Write(i); — print i, not j
End the rowConsole.WriteLine();
Letter from row indexchar ch = (char)('A' + row - 1);
One-line shortcutConsole.WriteLine(new string(ch, row));
Reverse twinProgram 10 (E, DD, CCC, …)

Write vs WriteLine

APIEffectUse for
Console.WriteStays on the same lineEach letter on the row
Console.WriteLineEnds the current lineAfter the inner loop

Live Preview

Change the row count and the repeating triangle updates instantly — capped at 26 letters (A–Z).

Whole numbers from 1 to 26. Tap a chip or type a value — the preview redraws as you go.

Live result 5 rows · 15 letters
A
BB
CCC
DDDD
EEEEE

Worked Walkthrough — rows = 4

Trace each outer-loop letter as i advances from 'A' to 'D'.

Letter iInner runsPrinted rowRepeats
'A'1A1
'B'2BB2
'C'3CCC3
'D'4DDDD4

Total letter prints: 1 + 2 + 3 + 4 = 10 = 4×5/2 — same triangular count as Program 1.

C# Programs

Three complete programs: fixed last letter, console input, and a new string shortcut. Use View Output to reveal sample results.

Example 1 — Fixed from 'A' to 'E'

Hard-coded last letter — outer loop picks the letter; inner loop only controls the repeat count.

C#
using System;

class Program
{
    static void Main()
    {
        for (char i = 'A'; i <= 'E'; i++)
        {
            for (char j = 'A'; j <= i; j++)
            {
                Console.Write(i);
            }
            Console.WriteLine();
        }
    }
}

How It Works

1. Outer loop picks the row letter. i runs from 'A' to 'E' — one letter per row.

2. Inner loop only counts. j runs from 'A' to i, so the width grows 1, 2, 3, …

3. Print i, not j. That keeps every character on the row the same. Printing j would rebuild Program 1.

When i = 'C' the inner loop runs three times and you get CCC.

Example 2 — User Input Version

Read the row count at runtime. Prefer int.TryParse and clamp to 26 (shown in the tip below).

C#
using System;

class Program
{
    static void Main()
    {
        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 j = 1; j <= row; j++)
            {
                Console.Write(ch);
            }
            Console.WriteLine();
        }
    }
}

How It Works

1. Prompt and read. Ask for a row count, then convert the line to an int.

2. Map row index to a letter. ch = (char)('A' + row - 1) — for row = 3, ch is 'C'.

3. Repeat ch exactly row times. Same uniform-row idea as Example 1, expressed with integer bounds.

4. Safer input tip. Convert.ToInt32 throws on letters. Prefer:

Safer input
if (!int.TryParse(Console.ReadLine(), out int rows) || rows < 1 || rows > 26)
{
    Console.WriteLine("Enter a whole number from 1 to 26.");
    return;
}

Example 3 — new string(ch, row)

Build each repeated-letter row in one call — same shape, no explicit inner letter loop.

C#
using System;

class Program
{
    static void Main()
    {
        int rows = 5;

        for (int row = 1; row <= rows; row++)
        {
            char ch = (char)('A' + row - 1);
            Console.WriteLine(new string(ch, row));
        }
    }
}

How It Works

1. Pick the letter from the row index. Same mapping as Example 2: row 1 → A, row 2 → B, and so on.

2. Fill a string of length row. new string(ch, row) creates a string filled with ch — e.g. new string('C', 3) is CCC.

3. Learn loops first. Use Examples 1–2 when you need to show nested bounds; treat this as a polish shortcut afterward.

Edge Cases & Pitfalls

Check these before calling the solution done.

Write(j)

Program 1 by mistake

Printing j instead of i produces A, AB, ABC. Use Console.Write(i) (or ch) for a uniform row.

WriteLine inside

Column of letters

If WriteLine is inside the inner loop, each letter lands on its own line. Use Write for letters; WriteLine only after the inner loop.

Off-by-one

Wrong letter mapping

Use (char)('A' + row - 1). Forgetting - 1 shifts every letter one step forward.

rows > 26

Past Z

'A' + row - 1 leaves A–Z when rows > 26. Clamp or reject in interactive programs.

rows = 1

Single A

Output is just A. A good sanity check for the mapping and the break.

Bad input

Use TryParse

Convert.ToInt32 throws on letters — prefer int.TryParse and require 1–26.

Time and Space Complexity

ProgramTimeExtra space
Nested loops (Examples 1–2)O(rows²)O(1)
new string (Example 3)O(rows²)O(rows) per temporary row string

Total letters = 1 + 2 + … + n = n(n + 1)/2 — quadratic in n. Same totals as Program 1.

Key Takeaways

  • Rule: outer loop picks the letter; inner loop only sets how many times to print it.
  • Print i, not j: that single choice separates this pattern from Program 1.
  • Break the row: call WriteLine only after the inner loop.
  • Complexity: O(n²) time from the triangular letter count; O(1) extra space for nested loops.

One line: for each letter i, print i exactly as many times as the row width, then WriteLine.

Frequently Asked Questions

Because the inner loop prints the outer-loop character (i) every time. The inner counter only controls how many times to print, not which character to print.
Then letters would change across the row (A, AB, ABC…), which is Program 1 — not a repeating-letter triangle.
On the third row the row letter is C, and the inner loop runs three times, printing C each time.
Program 1 prints stepping letters across each row (A, AB, ABC). This pattern keeps one letter per row and only grows the repeat count (A, BB, CCC).
Program 10 uses the same growing widths but letters count downward (E, DD, CCC…). This pattern counts upward (A, BB, CCC…).
Console.Write stays on the same line. Console.WriteLine ends the current line. Letters use Write; the row break uses WriteLine after the inner loop.
O(n²) for n rows, because total printed characters are n(n+1)/2.
Yes. Console.WriteLine(new string(ch, row)) prints a full repeated-letter row in one call. Nested loops are better for learning; the string constructor is a handy shortcut later.

Did you know?

Each row prints the same letter repeatedly: row 1 prints A once, row 2 prints B twice, row 3 prints C three times. Print the outer loop letter inside the inner loop so the row stays uniform. The reverse twin is Program 10.

Next: Reverse Repeating Triangle

Same growing widths, letters counting down from E.

Program 10 tutorial →

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