Reverse Right-Angled Triangle Alphabet Pattern in C

Beginner
⏱️ 5 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Nested Loops

What You’ll Learn

How to print a reverse alphabet right-angled triangle: each row has one more character than the last, and letters go from 'E' downward (for five rows) using printf("%c", ch--).

The result is E, ED, EDC, EDCB, EDCBA—same geometry as program 1, but descending along the alphabet each row.

⭐ Pattern Output

For 5 rows:

Output
E
ED
EDC
EDCB
EDCBA
1

Complete C Program

The outer loop walks rows; at the start of each row set ch = 'E', then the inner loop prints i letters with 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

1

Declare ch and loops

char ch; holds the current letter. i counts rows and j counts how many letters to print on that row.

Setup
2

Start each row at 'E'

Inside for (i = 1; i <= 5; ++i), the first statement is ch = 'E'; so every row begins from the same top letter before counting down.

Row prefix
3

Inner loop: print and decrement

printf("%c", ch--) outputs the current character, then moves ch to the previous ASCII letter. The inner loop runs i times.

Print & decrement
4

New line

printf("\n") after the inner loop finishes the row. The next outer iteration sets ch = 'E' again.

Line break
=

Reverse letter triangle

Again, total output length is 1+2+…+n characters, so time complexity is O(n²) for n rows.

2

Variation — User Input Version

For any row count rows, the last letter in the alphabet segment is 'A' + rows - 1. Set ch to that value at the beginning of each row:

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;
}

💡 Tips for Enhancement

Try These

  • Parameterize row count with scanf() and ch = 'A' + rows - 1 each row
  • Switch to ch++ and start at 'A' for the forward triangle (program 1)
  • Use 'e' / lowercase if you want a lowercase pattern
  • Omit the per-row ch = 'E' assignment to experiment with a continuous descending stream

Avoid

  • Saying “reset after the row” when the code actually assigns ch at the start of each row—both work logically, but match your source for clarity
  • Letting ch-- run past 'A' without bounds checks if you change row counts or logic
  • Using %d instead of %c for letters

Key Takeaways

1

Row i prints i characters, each row starting from the same high letter ('E' when rows == 5).

2

ch-- in printf prints the current letter, then moves backward in the alphabet.

3

For variable rows, use ch = 'A' + rows - 1 at the start of each outer iteration so the width of the alphabet matches the triangle height.

4

Complexity stays O(n²) for n rows, same as forward alphabet or star triangles.

❓ Frequently Asked Questions

You set ch = 'E' (for five rows) before the inner loop. Each iteration prints with printf("%c", ch--), so the row reads E, then ED, then EDC, and so on.
So each row starts from the same letter and only grows longer. Without that line, ch would keep decreasing across rows and the pattern would change completely.
Use ch++, start each row at 'A', and follow alphabet pattern program 1.
O(n²) for n rows: 1+2+…+n = n(n+1)/2 characters.

Explore More C Alphabet Patterns!

Combine forward, reverse, and mixed letter patterns to master character arithmetic in C.

All Alphabet Patterns →
Did you know?

ch-- in printf("%c", ch--) uses the post-decrement value for printing: you see the letter before ch moves backward, which matches how ch++ behaves for the forward triangle.

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