Reverse Triangle, E Always First in C

What You’ll Learn
Every line begins with 'E' and runs backward in the alphabet, but lines get shorter: EDCBA, EDCB, EDC, ED, E.
Compare program 7 (left edge steps E→D→C→ …) and program 6 (left edge steps A→B→ … toward E).
⭐ Pattern Output
For five rows with top letter 'E':
EDCBA
EDCB
EDC
ED
EComplete C Program (ASCII Values)
Outer: i from 65 ('A') to 69 ('E'). Inner: j from 69 down to i.
#include <stdio.h>
int main() {
int i, j;
for (i = 65; i <= 69; ++i) {
for (j = 69; j >= i; --j) {
printf("%c", j);
}
printf("\n");
}
return 0;
}Same with characters: for (i = 'A'; i <= 'E'; ++i) and for (j = 'E'; j >= i; --j).
🧠 How It Works
Outer loop raises the floor
i counts 'A' through 'E'. It is not printed first; it is the smallest code the inner loop may reach on that row.
Inner loop always starts at E
j starts at 69 every time, so the leftmost output is always 'E'.
j >= i
When i == 'A', j runs E down to A (five letters). When i == 'E', only j == E runs (one letter).
Characters per row
Row with bound i prints 69 - i + 1 characters (for ASCII E and A–E range).
Mixed loop directions
Outer ++ and inner -- are both fine in C; total work is still O(n²) for n rows in the general version.
Variation — User Input Version
endChar = 'A' + rows - 1 is both the first character each line prints (inner start) and the top of the outer range. i still runs from 'A' to endChar.
#include <stdio.h>
int main() {
int rows, i, j;
int endChar;
printf("Enter the number of rows: ");
scanf("%d", &rows);
endChar = 'A' + rows - 1;
for (i = 'A'; i <= endChar; ++i) {
for (j = endChar; j >= i; --j) {
printf("%c", j);
}
printf("\n");
}
return 0;
}💡 Tips for Enhancement
Try These
- Rewrite with only
charvariables if you prefer - Lowercase: set
endChar = 'a' + rows - 1and start inner at that letter - Relate to program 2 (also repeats an E-anchored idea per row, different inner rule)
- Validate
scanfand boundrows
Avoid
- Thinking
iis the first letter printed—it is the inner loop stop, not the first output - Using
j >= 65when you want shortening rows (that would repeat full width) - Confusing this with program 7 where the first letter changes each row
Key Takeaways
Inner loop starts at the top letter every row; outer loop only tightens how far down you go.
Mixed ++ and -- loops are normal when the pattern needs them.
O(n²) characters for n rows.
Dual of program 6 in a sense: fixed right end vs fixed left start (E).
❓ Frequently Asked Questions
j always initializes to 69 ('E') before counting down, so the first printf on each line is E.j may reach on that row. Larger i means a shorter run from E down to i.Explore More C Alphabet Patterns!
One loop forward and one backward is a common way to clip a triangle from a fixed corner.
The left column is always E and the right column steps A, B, C, D, E—the mirror of patterns where the right column is fixed and the left moves.
12 people found this page helpful
