Reverse Alphabet Decreasing Triangle in C

What You’ll Learn
Print a triangle whose first row is the full reverse run from E to A, then each row drops the leftmost letter: EDCBA, DCBA, CBA, BA, A.
This is the reverse-direction companion to program 6 (which grows from A toward a fixed E on the right). Here both edges march toward A.
⭐ Pattern Output
For five rows from 'E' down to 'A':
EDCBA
DCBA
CBA
BA
AComplete C Program (ASCII Values)
69 is 'E', 65 is 'A'. The inner j loop always ends at 65.
#include <stdio.h>
int main() {
int i, j;
for (i = 69; i >= 65; --i) {
for (j = i; j >= 65; --j) {
printf("%c", j);
}
printf("\n");
}
return 0;
}Equivalent with characters: for (i = 'E'; i >= 'A'; --i) and for (j = i; j >= 'A'; --j).
🧠 How It Works
Outer loop: high letter
i counts from 69 ('E') down to 65 ('A'). That is the first character on each row.
Inner loop: down to A
j runs from i down to 65, printing each code with printf("%c", j).
Row length
When the bottom letter is always 'A' (code 65), row starting at i has i - 65 + 1 characters.
New line
printf("\n") after the inner loop finishes one row before i decreases again.
Fifteen letters total
For n = 5 rows you print 5+4+3+2+1 = 15 characters — O(n²) for n rows in general.
Variation — User Input Version
high = 'A' + rows - 1 is the first row’s leftmost letter (e.g. 'D' for four rows). Loop i from high down to 'A'.
#include <stdio.h>
int main() {
int rows, i, j;
int high;
printf("Enter the number of rows: ");
scanf("%d", &rows);
high = 'A' + rows - 1;
for (i = high; i >= 'A'; --i) {
for (j = i; j >= 'A'; --j) {
printf("%c", j);
}
printf("\n");
}
return 0;
}💡 Tips for Enhancement
Try These
- Prefer
'E'/'A'bounds over raw numbers when you are not teaching ASCII - Lowercase: use
'a'as the floor and'a' + rows - 1as the ceiling - Compare with program 2 (each row starts at E and runs backward)
- Validate
scanfand keeprowsreasonable so'A' + rows - 1stays a letter you want
Avoid
- Mixing up program 6 (count up to E) with this pattern (count down to A)
- Using
++on both loops when you need reverse alphabetical order - Forgetting that
j >= 65(or>= 'A') must include the final A
Key Takeaways
Outer loop lowers the starting letter; inner loop prints down to a fixed 'A'.
Descending for loops match descending letters on the screen.
Still O(n²) characters for n rows.
Mirrors program 6 the same way program 5 mirrors program 1.
❓ Frequently Asked Questions
i picks the leftmost code each line (69, 68, …, 65). For each i, j runs from i down to 65, so the first line is the full descent to A, and later lines start lower.'A' and the row starts at code i, you print i - 'A' + 1 letters (as integers).Explore More C Alphabet Patterns!
Reverse loops are as common as forward loops for interview-style shapes.
The last column is always 'A' because the inner loop always stops there—symmetric to program 6, where the last column was always 'E'.
12 people found this page helpful
