Reverse Right-Angled Triangle Alphabet Pattern in C

Beginner
⏱️ 8 min read
📚 Updated: Aug 2026
🎯 3 Code Examples
🚀 Live Preview
Nested Loops

What You’ll Learn

Print a reverse alphabet right-angled triangle: each row has one more character than the previous, and letters go from a top letter down toward AE, ED, EDC, EDCB, EDCBA. Same geometry as Program 1, but descending along the alphabet. Includes a live preview, worked C examples, edge cases, and complexity.

Shape Rule

Growing reverse rows

Row k prints k letters from top down to a row end letter.

Outer Loop

Row end letter

for (char i = top; i >= 'A'; i--) picks the last letter.

Inner Loop

Always from top

j starts at top and prints down to i.

Char Arithmetic

j--

Decrementing a char walks the alphabet backward.

Live Preview

1–10 rows

Pick a height and draw the reverse triangle instantly.

O(n²)

Complexity

Triangular letter count: n(n+1)/2 writes.

Introduction

A reverse alphabet right-angled triangle grows like Program 1, but every row starts at a fixed top letter and counts downward until a row-specific end letter.

In C you solve it with nested char loops: the outer loop walks the end letter from top down to A, and the inner loop always restarts at top and prints down to that end.

Why it matters?

It locks in reverse character iteration — the same j-- skill used in many reverse triangles, diagonals, and mirrored alphabet labs.

Key Highlights

Growing Rows

1, 2, 3, … letters per row.

Always From Top

Inner loop restarts at the top letter.

Descending Letters

Print with j-- down to the end.

Mirror of Program 1

Same triangle; opposite letter direction.

In short: reset ch to the top letter each row (or loop j from top down to the row end), print with printf("%c", …), then printf("\n").

📝 Problem & Approach

Given a row count n (or fixed A–E), print a left-aligned triangle of descending alphabet prefixes.

c
// Five rows (top = E)
// E
// ED
// EDC
// EDCB
// EDCBA

Inputs & Outputs

ItemTypeDescription
rows / topint / charNumber of rows, or top letter where top = 'A' + rows - 1.
Printed outputtextGrowing reverse prefixes from top down to A on the last row.

Minimal workflow

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

Approach comparison

ApproachIdeaBest for
Char loops downOuter/inner both decrementMatching this classic sample
Index + char arrayWalk indices into A..ZWhen you already think in 0-based rows

⚡ Quick Reference

GoalPattern
Top letterchar top = (char)('A' + rows - 1);
Outer (end letter)for (char i = top; i >= 'A'; i--)
Inner (print)for (char j = top; j >= i; j--) printf("%c", j);
End the rowprintf("\n");
Forward triangleSee Program 1
LowercaseUse 'a' as the base instead of 'A'

📋 printf vs Direction

Same triangle idea as Program 1 — only letter direction changes.

printf("%c", ch--)
letter

Prints each descending letter on the current row

printf("\n")
break

Ends the row after the reverse run finishes

Program 2
E..down

Letters count down from top each row

Program 1
A..up

Letters count up from A each row

Context

When This Pattern Shows Up

Reach for this when teaching reverse character loops on a growing triangle.

  1. Right after Program 1

    Keep the triangle; flip letter direction to descending.

  2. Char decrement drills

    Practice j-- and j >= i bounds safely.

  3. Before Program 3

    Next you change only the starting letter while counting forward.

  4. Top-letter math

    Practice top = 'A' + rows - 1 for any height.

  5. Not a UI layout tool

    This is a console teaching pattern — not how you build modern app screens.

Key benefit: one bound change (j >= i with j--) turns a forward triangle into a reverse one.

🔮 Live Preview

Choose between 1 and 10 rows and draw the reverse alphabet triangle in the browser.

Try 5 (classic E…EDCBA) or 4 (D…DCBA). Max 10 keeps the preview readable.

Live result
Press "Draw pattern".

Examples Gallery

Three complete C programs — fixed top E, scanf row count, and spaced letters. . Click View Output to reveal sample console results.

📚 Getting Started

Print five reverse rows with nested char loops.

Example 1 — Fixed Top E

Each row resets ch = 'E', then prints i letters with printf("%c", ch--).

c
#include <stdio.h>

int main() {
    int i, j;
    char ch;

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

    return 0;
}

How It Works

When row length is 3, ch prints E, D, CEDC. When row length is 5, it prints the full reverse run EDCBA. Equivalent bound style: loop j from 'E' down to the row end letter.

📈 Practical Variant

Let the user choose how many rows to print.

Example 2 — Row Count Input

Read the number of rows and set ch = 'A' + rows - 1 at the start of each row. Check scanf in real apps.

c
#include <stdio.h>

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

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

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

    return 0;
}

How It Works

For 4 rows, each row starts at 'D'. Cap rows at 26 so the top letter stays within A–Z.

⚡ Readability Variant

Same reverse triangle with spaces between letters.

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 = top; i >= 'A'; --i) {
        for (j = top; j >= i; --j) {
            printf("%c ", j);
        }
        printf("\n");
    }

    return 0;
}

How It Works

Loop bounds are unchanged — only the printed unit becomes printf("%c ", j). Trim trailing spaces later if you need a compact line.

🧠 How the Algorithm Prints Rows

1

Outer loop (rows)

Grow width with i = 1..rows (or run i from top down to 'A'). Reset ch to the top letter each row.

Row control
2

Inner loop (descending)

Reset ch to top and print with printf("%c", ch--) (or loop j from top down to the row end).

Print letters
3

New line

printf("\n") ends the current row and moves to the next line.

Next row
4

Repeat until A

Rows grow by one letter each time until the full reverse run prints.

Grow
=

Reverse letter triangle

You print 1+2+…+n letters — O(n²) time, O(1) extra memory.

🔎 Worked Walkthrough — top E

Trace each outer value of i and the letters printed on that row.

i (end)Inner j rangePrinted row
EE..EE
DE..DED
CE..CEDC
BE..BEDCB
AE..AEDCBA

Total letters: 1 + 2 + 3 + 4 + 5 = 15 = 5×6/2.

Use Cases

Where this reverse triangle (and its descending loops) shows up beyond the homework prompt.

1. Direction Practice

Clearest alphabet demo of counting letters downward.

Example: flip bounds to Program 1 and compare.

2. Pair with Program 1

Same triangle geometry — forward vs reverse fill.

Example: print both side by side for n = 5.

3. Top-Letter Labs

Practice computing top from a row count.

Example: rows 1..10 map to A..J.

4. Spaced Output

Add separators without changing loop structure (Example 3).

Example: print printf("%c ", j) for readable columns.

5. Complexity Intuition

Triangular sums make O(n²) easy to see.

Example: 5 rows print 15 letters total.

6. Alphabet Caps

Practice limiting input so top stays in A–Z.

Example: reject rows > 26 or clamp it.

Pro Tip: say “always start at top, stop at the row end letter” before coding — that story prevents wrong inner bounds.

Advantages

Why this pattern earns a spot right after the forward alphabet triangle.

  1. 1. Instant Visual Feedback

    Wrong direction or bounds show up immediately as a non-reverse triangle.

  2. 2. Tiny Change from Program 1

    Same structure; only loop direction and comparison flip.

  3. 3. Natural Char Decrement

    C char arithmetic makes reverse walks feel natural.

  4. 4. O(1) Extra Memory

    Streaming output needs no storage beyond loop variables.

Pro Tip: master Program 1 first; treat this page as the same story with arrows reversed.

Usage Tips

Small habits that keep reverse-triangle code clean.

  1. 1. Restart Inner at Top

    Every row starts from the same top letter; only the end changes.

  2. 2. Use j >= i with j--

    That pair is what produces E, ED, EDC, …

  3. 3. Check scanf

    Avoid crashes when the user types letters instead of a number.

  4. 4. Cap at 26 Rows

    Beyond Z you need a wrap/stop policy for top.

  5. 5. Dry-Run Row C

    Trace E D C on paper before coding larger n.

Pro Tip: if every row starts with a different letter and runs forward to E, you wrote Program 3 — not this pattern.

Common Pitfalls

Mistakes that commonly break reverse alphabet triangles.

  1. 1. Using Forward Inner Bounds

    Writing j = 'A'; j <= i; j++ prints Program 1 instead.

    → Use j = top; j >= i; j--.

  2. 2. Wrong Comparison

    j > i skips the end letter on every row.

    → Keep j >= i so the row end letter is included.

  3. 3. Overflowing Z

    Large rows makes top walk past Z.

    → Cap input at 26 or define a wrap policy.

  4. 4. Unchecked scanf

    Letters or empty input leave rows uninitialized.

    → Check scanf’s return value and re-prompt on failure.

  5. 5. Skipping printf("\n")

    All letters print on one continuous line.

    → Call printf("\n") after each inner loop finishes.

Edge Cases

Check these inputs before calling the solution done.

rows = 1

Single letter

Output is just A.

rows = 5

Classic sample

Through EDCBA.

rows = 4

Shorter triangle

Top is D → DDCBA.

rows > 26

Past Z

Reject, clamp, or wrap — decide explicitly.

Bad input

Non-numeric scanf

Unchecked scanf fails silently — check the return value.

Case

Lowercase

Same loops with 'a' as the base.

🎯 Practice Problems

Try these variations to lock in the pattern.

1. Flip to forward

2. Add spaces

  • Print with printf("%c ", j) (Example 3)
  • Keep the same loop bounds

3. Change only the start

4. Star triangle twin

Notes

  • Same top every row. Only the end letter moves downward as rows grow.
  • Total letters for n rows is the triangular number n(n+1)/2.
  • Compute top = (char)('A' + rows - 1) to generalize any height.
  • This is the descending mirror of Program 1’s forward triangle.

Quick Takeaway: start every row at the top letter, print down to the row end, then break the line — that is the whole triangle.

⏱️ Time and Space Complexity

ProgramTimeExtra space
Fixed / input (Examples 1–2)O(n²)O(1)
Spaced letters (Example 3)O(n²)O(1)

Row k prints k letters; summing 1..n gives n(n+1)/2 character writes.

Wrap Up

🎉 Conclusion

The reverse alphabet right-angled triangle is a small nested-loop exercise with lasting payoff: fixed top letter, descending inner walk, and growing row length. Master the classic E…EDCBA sample, then try user input and optional spacing.

Practice the three examples above, then continue to Program 3’s triangle where each row starts one letter earlier but still runs forward.

Compute a top letter, print top..i on each row, and break only after the inner loop finishes.

💡 Best Practices

✅ Do

  • Restart the inner loop at top every row
  • Use j >= i with j-- for descending output
  • Compute top = (char)('A' + rows - 1)
  • Check scanf and cap at 26
  • State O(n²) when asked about complexity

❌ Don’t

  • Use forward A..i bounds for this pattern
  • Skip printf("\n") after each row
  • Let rows exceed 26 without a policy
  • Confuse this with Program 3’s changing start letter
  • Assume empty input is safe for scanf

Key Takeaways

Knowledge Unlocked

Five things to remember about this alphabet pattern

Print the reverse alphabet right-angled triangle the beginner-friendly way.

5
Core concepts
T 02

Top

Inner always starts here

Code
-- 03

Direction

j-- down to i

Code
04

New line

Ends each row

I/O
O 05

Complexity

O(n²) time

Analysis

❓ Frequently Asked Questions

The outer loop sets the last letter on each row from E down to A. For each outer letter i, the inner loop starts at E and prints down to i, so rows grow longer while letters remain in reverse order.
Because the inner loop always starts at top (E in the fixed example). Only the end letter changes with the outer-loop bound, so the triangle grows by one character each row.
Yes. Read rows with scanf and set top = 'A' + rows - 1. Then loop i from top down to 'A' and print j from top down to i.
Use Program 1: loop upward from 'A' and print to the current end letter. This page is the descending mirror of that pattern.
printf("%c", j) stays on the same line for each letter. printf("\n") ends the row after the inner loop finishes.
O(n²) for n rows, because the total printed letters are 1+2+...+n = n(n+1)/2.
Check scanf("%d", &rows) == 1, require n ≥ 1, and cap at 26 so the top letter stays within A–Z.
Yes. Use 'a' as the base: top = 'a' + rows - 1, then loop the same way downward.

Did you Know? 🔊

This reverse right-angled alphabet triangle prints letters from a top letter down to A on each row. For 5 rows, the output is E, ED, EDC, EDCB, and EDCBA. In C, ch-- or looping j from top down to i both walk the alphabet backward.

Continue to Alphabet Pattern 3

Next up: reverse starting letter patterns with nested loops.

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