C Repeating Alphabet Triangle Pattern (Reverse)

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

What Is This Pattern?

A reverse repeating alphabet triangle grows by one repeated letter on each new line while letters count downward from the top of the alphabet range.

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

E
DD
CCC
BBBB
AAAAA     ← 5 rows (top = 'E')

It is the reverse of Program 9: same growing widths, but letters step E → A instead of A → E. Print the outer letter inside the inner loop so each row stays uniform. Flip the widths in Program 11 to get the inverted twin.

How to Solve It

Two ways to emit the same shape — start with nested char loops and printf, then optionally polish with putchar.

MethodIdeaBest for
Nested loops + printfOuter = letter; inner = growing width; print outer letterLearning, interviews, exams
Nested loops + putcharSame loops; putchar(i) per letterSlightly leaner demos once loops click

Pseudocode

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

Cheat sheet

GoalPattern
Countdown lettersfor (i = top; i >= 'A'; i--)
Grow widthfor (j = top; j >= i; j--)
Uniform rowprintf("%c", i); — print i, not j
End the rowprintf("\n");
Top from rowstop = (char)('A' + rows - 1);
putchar styleputchar(i); then putchar('\n');
Forward twinProgram 9 (A, BB, CCC, …)

Printing Letters vs Starting a New Line

APIEffectUse for
printf("%c", i)Stays on the same lineEach letter on the row
printf("\n")Ends the current lineAfter the inner loop

Live Preview

Change the height and the reverse 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
E
DD
CCC
BBBB
AAAAA

Worked Walkthrough — 'E' down to 'A'

Trace each outer-loop value of i and count how many times the inner loop runs.

iInner j rangePrinted rowRepeats
'E''E'..'E'E1
'D''E'..'D'DD2
'C''E'..'C'CCC3
'B''E'..'B'BBBB4
'A''E'..'A'AAAAA5

Total letter prints: 1 + 2 + 3 + 4 + 5 = 15 = 5×6/2. That triangular sum is why time is O(n²).

C Programs

Three complete programs: fixed letters, scanf input, and a putchar shortcut. Use View Output to reveal sample results.

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

Hard-coded range — outer letter counts down; inner loop grows and prints that letter.

C
#include <stdio.h>

int main(void)
{
    char i, j;

    for (i = 'E'; i >= 'A'; i--)
    {
        for (j = 'E'; j >= i; j--)
        {
            printf("%c", i);
        }
        printf("\n");
    }

    return 0;
}

How It Works

1. Outer loop picks the letter. i runs from 'E' down to 'A'.

2. Inner loop sets the width. j runs from 'E' down to i — once for E, twice for D, and so on.

3. Print the outer letter. printf("%c", i) keeps the whole row the same character.

4. Break the line. printf("\n") after the inner loop starts the next row.

Example 2 — User Input Version

Read the row count with scanf, set top = 'A' + rows - 1, then use the same countdown core. Always check scanf in real apps.

C
#include <stdio.h>

int main(void)
{
    int rows;
    char i, j, top;

    printf("Enter the number of rows: ");
    scanf("%d", &rows);
    top = (char)('A' + rows - 1);

    for (i = top; i >= 'A'; i--)
    {
        for (j = top; j >= i; j--)
        {
            printf("%c", i);
        }
        printf("\n");
    }

    return 0;
}

How It Works

1. Prompt and read. Ask for a row count, then store it with scanf("%d", &rows).

2. Compute the top letter. For rows = 4, top is 'D' — first row is D.

3. Same countdown core. Only the source of top changes — the print logic matches Example 1.

4. Safer input tip. Unchecked scanf leaves rows uninitialized on bad input. Prefer:

Safer input
if (scanf("%d", &rows) != 1 || rows < 1 || rows > 26)
{
    printf("Enter a whole number from 1 to 26.\n");
    return 1;
}

Example 3 — putchar(i)

Same nested loops — write each letter with putchar instead of printf.

C
#include <stdio.h>

int main(void)
{
    char i, j;

    for (i = 'E'; i >= 'A'; i--)
    {
        for (j = 'E'; j >= i; j--)
        {
            putchar(i);
        }
        putchar('\n');
    }

    return 0;
}

How It Works

1. Same outer and inner bounds. Still count i down from 'E' and grow width with j from 'E' to i.

2. One character at a time. putchar(i) writes the outer letter without a format string.

3. End the row. putchar('\n') advances to the next line.

Learn the printf version first (Examples 1–2); treat putchar as a polish shortcut afterward.

Edge Cases & Pitfalls

Check these before calling the solution done.

printf(j)

Letters change across the row

Printing j instead of i produces reverse runs like Program 7. Use printf("%c", i) for a uniform row.

i++

Program 9 by mistake

If the outer loop increments from A, you get A, BB, CCC. Count down from top for this pattern.

\n inside

Column of letters

If printf("\n") is inside the inner loop, each letter lands on its own line. Call it only after the inner loop.

rows > 26

Past Z

'A' + rows - 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.

scanf

Check the return value

If scanf fails, rows may be uninitialized — always test scanf(...) == 1 and prefer 1–26.

Time and Space Complexity

ProgramTimeExtra space
Nested loops + printf (Examples 1–2)O(rows²)O(1)
putchar (Example 3)O(rows²)O(1)

Total letters printed = 1 + 2 + … + n = n(n+1)/2, which is still quadratic in n.

Key Takeaways

  • Rule: count letters down from the top; grow the repeat count each row.
  • Print i, not j: that keeps each row a single repeated letter.
  • Break the row: call printf("\n") only after the inner loop.
  • Complexity: O(n²) time from the triangular letter count; O(1) extra space.

One line: for each letter i from the top down to A, print i with a growing width, then printf("\n").

Frequently Asked Questions

Program 9 uses A, BB, CCC, ... (letters increase). Program 10 uses E, DD, CCC, ... (letters decrease) with the same growing repeat counts.
On the 4th row the outer-loop letter is B, and the inner loop runs four times, printing B each time.
j only controls how many times the loop runs. Printing i keeps the row the same letter; printing j would change letters across the row.
With for (j = top; j >= i; j--), when i is near the top the range is short; as i moves toward A the range lengthens, so repeat counts grow 1, 2, 3, …
printf("%c", i) prints a letter and stays on the same line. printf("\n") ends the current line. Letters use %c; the row break uses \n after the inner loop.
O(n²) where n is the number of rows. Total letter prints equal 1+2+…+n = n(n+1)/2.
Yes. putchar(i) writes one character without a format string. Nested loops with putchar are a common, slightly leaner style; keep printf if your course examples use it.
Check scanf's return value: if (scanf("%d", &rows) != 1) handle bad input. Clamp rows between 1 and 26 so bad input does not leave rows uninitialized or walk past A.

Did you know?

This pattern is the reverse of Program 9: row widths still grow 1, 2, 3, …, but letters run backward (E, then D, then C, …). Print the outer loop letter inside the inner loop so each row stays uniform.

Next: Inverted Repeating Triangle

Shrink the repeat count while letters still count down.

Program 11 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