C Reverse Alphabet Triangle Pattern (Fixed Start)

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

What Is This Pattern?

A reverse alphabet triangle with a fixed start keeps the same leftmost letter on every row and shortens only the right side — classic five-row sample: EDCBA, EDCB, EDC, ED, E.

Remember
Rule: left edge stays at top; floor i walks A..top; print j from top..i

EDCBA
EDCB
EDC
ED
E     ← 5 rows (top = E)

Unlike Program 7 (first letter moves: E, then D, then C…), here every row begins at the same top letter while the stopping point rises.

How to Solve It

Outer loop raises the floor; inner loop always starts at top and counts down to that floor.

MethodIdeaBest for
Fixed floor walkOuter i from A..top; inner j from top..iLearning, interviews, fixed demos
Row counttop = 'A' + rows - 1, then same loopsUser input for height

Pseudocode

Pseudocode
top = 'A' + rows - 1
for i from 'A' to top:
    for j from top down to i:
        print j (no newline)
    print newline

Cheat sheet

GoalPattern
Raise the floorfor (char i = 'A'; i <= top; i++)
Print top..ifor (char j = top; j >= i; j--) printf("%c", j);
Compute top from rowstop = (char)('A' + rows - 1);
Spaced lettersprintf("%c ", j);
End the rowprintf("\n");
A–Z-safe heightClamp rows to 1–26

Printing Letters vs Starting a New Line

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

Print characters without a newline, then end the row once.

Live Preview

Change the row count and the fixed-start reverse triangle updates instantly — including top letter and letter totals.

Whole numbers from 1 to 10. Top letter is A + rows - 1; total letters equal n(n+1)/2.

Live result 5 rows · top E · 15 letters
EDCBA
EDCB
EDC
ED
E

Worked Walkthrough — top = 'E'

Trace each floor letter i and the reverse run printed from E down to i.

iInner jPrinted rowCount
AE..AEDCBA5
BE..BEDCB4
CE..CEDC3
DE..DED2
EE..EE1

Total letters: 5 + 4 + 3 + 2 + 1 = 15 = n(n+1)/2. Every row starts on E because the inner loop always begins at top.

C Programs

Three complete programs: fixed top E, row-count input, and spaced letters. Use View Output to reveal sample results.

Example 1 — Fixed Top E

Outer loop raises the stopping letter; inner loop always starts at E and counts down.

C
#include <stdio.h>

int main() {
    char i, j;

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

    return 0;
}

How It Works

1. Outer loop raises the floor. i walks A, B, C, D, E — the last letter allowed on each row.

2. Inner loop always starts at E. From 'E' down to i. When i = 'C', that is EDC.

3. Break the line. printf("\n") after the inner loop starts the next shorter reverse prefix.

Example 2 — Row Count Input

Read the number of rows and compute top = 'A' + rows - 1. Check scanf in real apps.

C
#include <stdio.h>

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

    printf("Enter the number of rows: ");
    scanf("%d", &rows);

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

    return 0;
}

How It Works

1. Map rows → top. For 4 rows, top becomes 'D'.

2. Same nested-loop core. Only the bounds follow top instead of the literal 'E'.

3. Safer input tip. Check scanf and stay within A–Z:

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

Example 3 — Spaced Letters

Print a trailing space after each letter so columns are easier to scan.

C
#include <stdio.h>

int main() {
    char top = 'E';
    char i, j;

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

    return 0;
}

How It Works

1. Same bounds. Outer and inner loops match Example 1 — only the printed unit changes.

2. Letter plus space. printf("%c ", j) makes columns easier to read at a glance.

3. Compact tip. Trim trailing spaces later if you need a tight line without a final space.

Edge Cases & Pitfalls

Check these before calling the solution done.

j from i

Wrong pattern

Starting the inner loop at i (instead of top) prints Program 7 style — changing the first letter each row.

j >= A

No shrinking

Using j >= 'A' instead of j >= i prints the full reverse run on every row.

Missing \\n

One long line

Call printf("\n") after each inner loop. Without it, every letter lands on one line.

rows = 1

Single A

Output is just A — a good sanity check.

Past Z

Clamp to 26

More than 26 rows walks top past Z. Cap or reject the input.

scanf fail

Unchecked input

Always check scanf("%d", &rows) == 1 so bad input does not leave rows uninitialized.

Time and Space Complexity

ProgramTimeExtra space
Fixed / input / spaced formsO(n²)O(1)

Total letters printed = n + (n-1) + … + 1 = n(n+1)/2, which is quadratic in the number of rows.

Key Takeaways

  • Left edge is fixed: every row starts at top; the floor i walks A..top.
  • Inner starts at top: print top..i so the tail shortens, not the left edge.
  • Vs Program 7: first letter stays the same; it does not walk backward each row.
  • Complexity: O(n²) time; O(1) extra space.

One line: for each rising floor, print top..floor, then printf("\n").

Frequently Asked Questions

Because the inner loop always starts at the top letter (E in the 5-row example) and counts down. So the first printed character each row is always E.
The outer loop increases the stopping point for the inner loop. That shortens the tail each row, producing EDCBA, then EDCB, then EDC, and so on.
Program 7 changes the first letter each row (E, then D, then C…). Program 8 keeps the first letter fixed and only shortens the tail.
Program 5 prints forward prefixes from A (ABCDE, ABCD, …). This pattern prints reverse prefixes from a fixed top (EDCBA, EDCB, …). Same shrinking idea; opposite letter direction and left edge.
Every row would print the full reverse run (EDCBA each time) with no shrinking.
O(n²) for n rows, because total printed characters are n(n+1)/2.
Yes. Read rows with scanf, set top = (char)('A' + rows - 1), then loop i from 'A' to top and print j from top down to i.
Check scanf("%d", &rows) == 1, require n ≥ 1, and cap at 26 so the top letter stays within A–Z.

Did you know?

Every row begins with the same top letter because the inner loop always starts there. The outer loop only raises the stopping point, so the tail shortens: EDCBA, EDCB, EDC, ED, E.

Next: Repeating Alphabet Triangle

Repeat the same letter across each row of a growing triangle.

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