Reverse Right-Angled Triangle Alphabet Pattern in C

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:
E
ED
EDC
EDCB
EDCBAComplete 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--.
#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
Declare ch and loops
char ch; holds the current letter. i counts rows and j counts how many letters to print on that row.
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.
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.
New line
printf("\n") after the inner loop finishes the row. The next outer iteration sets ch = 'E' again.
Reverse letter triangle
Again, total output length is 1+2+…+n characters, so time complexity is O(n²) for n rows.
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:
#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()andch = 'A' + rows - 1each 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
chat 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
%dinstead of%cfor letters
Key Takeaways
Row i prints i characters, each row starting from the same high letter ('E' when rows == 5).
ch-- in printf prints the current letter, then moves backward in the alphabet.
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.
Complexity stays O(n²) for n rows, same as forward alphabet or star triangles.
❓ Frequently Asked Questions
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.ch would keep decreasing across rows and the pattern would change completely.Explore More C Alphabet Patterns!
Combine forward, reverse, and mixed letter patterns to master character arithmetic in C.
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.
12 people found this page helpful
