Reverse Order Alphabet Triangle in C

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

What You’ll Learn

Print a right-angled triangle where the first character of each row moves forward (A, B, C, D, E), but each row prints letters in reverse order down to A: A, BA, CBA, DCBA, EDCBA. Compare with Program 1 (forward along each row) and Program 3 (reverse starting letter, forward along row). Includes a live preview, worked C examples, edge cases, and complexity.

Shape Rule

Left grows

Highest letter A → E; row length grows 1..n.

Inner Loop

j-- to A

Print from the row’s peak letter down to A.

Right Edge

Always A

Every row ends at A — a vertical right edge.

vs Program 1

Direction

Same growth; letters run backward, not forward.

Live Preview

Rows 1–10

Pick a row count and draw BA / CBA / … live.

O(n²)

Complexity

1+2+…+n printed characters total.

Introduction

A reverse-order alphabet triangle grows like Program 1, but each row prints its letters descending to A instead of ascending from A.

In C you raise the peak letter with the outer loop (i++) and count down with the inner loop (j--) until you hit 'A'.

Why it matters?

It shows how flipping only the inner loop direction turns A, AB, ABC into A, BA, CBA — a classic nested-loop direction drill.

Key Highlights

Outer

i from A to top.

Inner

j from i down to A.

Edge

Every row ends at A.

Output

A, BA, CBA, …

In short: for each peak letter i from 'A' to top, print j from i down to 'A', then call printf("\n").

📝 Problem & Approach

Given a row count (or fixed top E), print a right-angled triangle where each row starts at a higher letter and counts down to A.

c
// Five rows (top = E)
// A
// BA
// CBA
// DCBA
// EDCBA

Inputs & Outputs

ItemTypeDescription
rows / topint / charNumber of rows; top letter is 'A' + rows - 1 (E for 5).
Printed outputtextGrowing reverse-order lines ending at A on every row.

Minimal workflow

Pseudocode
top = 'A' + rows - 1
for i from 'A' to top:          // peak letter grows
    for j from i down to 'A':   // reverse along the row
        print j
    print newline

Approach comparison

ApproachIdeaBest for
Char nested loopsOuter i++, inner j-- to AMatching this classic sample
Index + alphabet arrayPrint alpha[k] for k = i..0When you already use string indexes

⚡ Quick Reference

GoalPattern
Fixed A–Efor (char i = 'A'; i <= 'E'; i++)
Reverse along rowfor (char j = i; j >= 'A'; j--) printf("%c", j);
User rowsfor (char i = 'A'; i < 'A' + rows; i++)
Forward insteadSee Program 1 (j from A up to i)
Reverse start, forward runSee Program 3

📋 Prog 1 vs Prog 3 vs Prog 4

Same growing triangle — different letter direction and edges.

Program 1
A..i

Forward from A; left edge fixed

Program 3
i..top

Forward to top; right edge fixed

Program 4
i..A

Backward to A; right edge fixed

printf("\n")
break

Ends the row after the descent

Context

When This Pattern Shows Up

Reach for this when teaching a growing peak letter with a descending letter run.

  1. After Program 1

    Keep the triangle; flip only the inner loop to j--.

  2. Fixed right-edge drills

    Practice prefixes that always end at the same letter (A).

  3. Contrast with Program 3

    Both fix one edge; this one fixes A on the right with a reverse run.

  4. Char arithmetic practice

    Mix i++ with j-- in the same program.

  5. Not a UI layout tool

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

Key benefit: one growing peak plus a descending inner loop is the cleanest way to keep a fixed A on the right while rows grow.

🔮 Live Preview

Choose 1–10 rows and draw the reverse-order alphabet triangle in the browser.

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

Live result
Press "Draw pattern".

Examples Gallery

Three complete C programs — fixed A–E, scanf row count, and a spaced-letter variant. Click View Output to reveal sample console results.

📚 Getting Started

Print five rows with a growing peak and a reverse letter run.

Example 1 — Fixed Top E

Outer loop picks the highest letter on each row; inner loop prints from that letter down to 'A'.

c
#include <stdio.h>

int main() {
    char i, j;

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

    return 0;
}

How It Works

When i = 'C', the inner loop prints C, B, ACBA. When i = 'E', it prints the full reverse run EDCBA.

📈 Practical Variant

Let the user choose how many rows to print.

Example 2 — Row Count Input

Read the number of rows and loop i from 'A' to 'A' + rows - 1. Check scanf in real apps.

c
#include <stdio.h>

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

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

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

    return 0;
}

How It Works

For 4 rows, i runs through A..D. Cap rows at 26 so the peak letter stays within A–Z.

⚡ Readability Variant

Same 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 i, j;

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

    return 0;
}

How It Works

Loop bounds are unchanged — only the printed unit becomes j + " ". Trim trailing spaces later if you need a compact line.

🧠 How the Algorithm Prints Rows

1

Outer loop: raise the peak

i runs from 'A' to top. Row length grows because later rows start at a higher letter.

Row control
2

Inner loop: print backward

For each row, j starts at i and counts down to 'A'. Printing j produces BA, CBA, DCBA, and so on.

Reverse along row
3

New line

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

Line break
4

Right edge stays A

Because the inner loop always stops at 'A', every row ends on A while the left side grows.

Alignment
=

Reverse-order triangle

Total printed characters are 1+2+…+n, so time complexity is O(n²).

🔎 Worked Walkthrough — Top = E (5 rows)

Trace each peak letter and the resulting reverse run down to A.

i (peak)Inner rangePrinted row
AA..AA
BB..ABA
CC..ACBA
DD..ADCBA
EE..AEDCBA

Row lengths are 1, 2, 3, 4, 5. The right edge is always A.

Use Cases

Where this reverse-order alphabet triangle shows up beyond the homework prompt.

1. Direction Labs

Clearest demo of flipping only the inner loop.

Example: change j-- to j++ and compare with Program 1.

2. Edge Practice

Fixed right edge (A) with a growing left edge.

Example: stack next to Program 3’s fixed E edge.

3. Char Bounds

Practice inclusive descending ranges ending at 'A'.

Example: off-by-one if you stop at 'B'.

4. Input Scaling

Map row count to peak letter with 'A' + rows - 1.

Example: scale from 5 to 8 without rewriting loops.

5. Complexity Intuition

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

Example: 15 letters for 5 rows.

6. Series Continuity

Sits between Programs 3 and 5 in the alphabet set.

Example: revisit Program 1.

Pro Tip: say “raise the peak, then walk down to A” before coding — that story prevents writing a forward inner loop by habit.

Advantages

Why this pattern earns a spot early in the alphabet-pattern series.

  1. 1. Instant Visual Feedback

    A forward row or missing A shows up immediately.

  2. 2. Tiny Diff from Program 1

    Only the inner step direction changes.

  3. 3. Scales Cleanly

    Change the top letter or row count and the whole triangle grows.

  4. 4. Beginner-Friendly

    No padding or diagonal checks — just two char loops.

Pro Tip: master Program 1 first; this page is mostly “same outer loop, count down instead of up.”

Usage Tips

Small habits that keep reverse-order alphabet triangles clean.

  1. 1. Count Down to A Inclusive

    Use j >= 'A' so every row still ends with A.

  2. 2. Start the Inner Loop at i

    Starting at a fixed letter breaks the growing left edge.

  3. 3. Cap Rows at 26

    Keep the peak letter inside A–Z when taking user input.

  4. 4. Check scanf

    Validate the row count and check scanf’s return value.

  5. 5. Compare with Program 1 Side by Side

    Same outer loop; only j++ vs j-- differs.

Pro Tip: if you see A, AB, ABC, the inner loop is still incrementing — switch to j--.

Common Pitfalls

Mistakes that commonly break reverse-order alphabet triangles.

  1. 1. Using j++ in the Inner Loop

    Prints Program 1 instead of BA / CBA.

    → Use for (char j = i; j >= 'A'; j--).

  2. 2. Stopping Before A

    Using j > 'A' drops the trailing A on every row.

    → Keep the condition inclusive: j >= 'A'.

  3. 3. Letting Rows Past Z

    'A' + rows - 1 can leave the alphabet.

    → Cap rows at 26 (or handle wrap explicitly).

  4. 4. Unchecked scanf

    Empty or non-numeric input leaves rows unused or uninitialized.

    → Check scanf’s return value and validate range.

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

    All letters dump onto one line.

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

Edge Cases

Check these inputs before calling the solution done.

rows = 1

Single letter

Output is just A.

rows = 5

Classic sample

A through EDCBA (Example 1).

rows = 4

Smaller triangle

Ends at DCBA (Example 2).

rows > 26

Past Z

Cap or reject — peak leaves the alphabet.

Bad input

Empty / non-numeric

Check scanf’s return value.

Lowercase

a, ba, cba

Swap 'A' for 'a' in both loops.

🎯 Practice Problems

Try these variations to lock in the pattern.

1. Flip to Program 1

  • Change only the inner loop to j++
  • Confirm you get A, AB, ABC

2. Right-align with spaces

  • Print leading spaces before the letters
  • Keep the reverse letter run unchanged

3. Scale to 8 rows

  • Use the input version
  • Check the last row is HGFEDCBA

4. Compare with Program 3

Notes

  • Peak grows. Outer i++ raises the first letter of each row.
  • The inner loop always ends at 'A', so the right edge is vertical.
  • Row lengths are 1, 2, …, n — same geometry as Program 1.
  • Next up: Alphabet Pattern 5 continues the series.

Quick Takeaway: raise the peak letter with the outer loop, then walk down to A with the inner loop — that alone builds A, BA, CBA, …

⏱️ Time and Space Complexity

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

For n rows you print 1+2+…+n = n(n+1)/2 characters, so total work is O(n²).

Wrap Up

🎉 Conclusion

The reverse-order alphabet triangle is Program 1 with a descending inner loop: the peak letter grows A…E while each row walks back down to A. Master the classic A…EDCBA sample, then try user input and the spaced rewrite.

Practice the three examples above, then continue to Alphabet Pattern 5.

Outer i from A to top, inner j from i down to A, then break each line.

💡 Best Practices

✅ Do

  • Start the inner loop at i and count down to 'A'
  • Keep j >= 'A' inclusive
  • Cap user row counts at 26
  • Compare side by side with Program 1
  • State O(n²) when asked about complexity

❌ Don’t

  • Use j++ when you want BA / CBA
  • Stop the inner loop before 'A'
  • Let 'A' + rows go past 'Z'
  • Skip validating row-count input
  • Call printf("\n") inside the letter loop

Key Takeaways

Knowledge Unlocked

Five things to remember about this alphabet pattern

Print the reverse-order alphabet triangle the beginner-friendly way.

5
Core concepts
= 02

Inner

j from i to A

Code
1 03

Edge

Every row ends at A

Shape
R 04

vs Prog 1

Only direction flips

Compare
O 05

Complexity

O(n²) time

Analysis

❓ Frequently Asked Questions

The outer loop selects the highest letter on the row (A to E). The inner loop starts at that letter and decrements down to 'A', printing each character, so each row reads backward.
Because the inner loop always runs until j == 'A', so the last printed character on every row is A.
Program 1 prints forward along each row (A, AB, ABC). This pattern prints backward down to A (A, BA, CBA) while the left edge still grows A, B, C, …
Program 3 starts earlier each row but still prints forward to a fixed top (E, DE, CDE). This pattern starts later each row and prints backward to a fixed A.
O(n²) for n rows, because the total printed letters are 1+2+...+n = n(n+1)/2.
Yes. Read rows with scanf and loop i from 'A' to 'A' + rows - 1, with the inner loop counting down from i to 'A'.
Check scanf("%d", &rows) == 1, require n ≥ 1, and cap at 26 so the highest letter stays within A–Z.
Yes. Start from 'a' and loop the same way: outer i from 'a' up, inner j from i down to 'a'.

Did you Know? 🔊

Each row starts one letter later (A, B, C, …), but prints backward down to A. For 5 rows, the output is A, BA, CBA, DCBA, EDCBA.

Explore More C Alphabet Patterns!

Small changes in loop direction completely change the output — keep experimenting.

All Alphabet Patterns →

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