Inverted Right-Angled Alphabet Triangle in C

What You’ll Learn
Print an inverted letter triangle: the first row is the longest (ABCDE for five rows), then each row drops one letter while still starting from 'A' and counting up.
This is the natural partner to program 1 (growing rows); only the outer loop direction changes.
⭐ Pattern Output
For 5 rows:
ABCDE
ABCD
ABC
AB
AComplete C Program (Fixed Rows)
Outer loop: i from rows down to 1. Before the inner loop, set currentChar = 'A'; inner loop runs i times printing and incrementing.
#include <stdio.h>
int main() {
int rows = 5;
int i, j;
char currentChar;
for (i = rows; i >= 1; --i) {
currentChar = 'A';
for (j = 1; j <= i; ++j) {
printf("%c", currentChar++);
}
printf("\n");
}
return 0;
}🧠 How It Works
Reverse outer loop
for (i = rows; i >= 1; --i) makes the first printed line use the largest i (widest row).
Restart at A each line
currentChar = 'A' at the beginning of each outer iteration so every row reads A, AB, ABC, … not a continued alphabet.
Inner loop length = i
for (j = 1; j <= i; ++j) prints exactly i letters on this line.
New line
printf("\n") after the inner loop ends the row before i decreases.
Inverted triangle
Total characters: rows + (rows-1) + ... + 1 = rows(rows+1)/2 — O(n²) for rows = n.
Variation — User Input Version
Read rows with scanf(); the same nested loops apply.
#include <stdio.h>
int main() {
int rows, i, j;
char currentChar;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (i = rows; i >= 1; --i) {
currentChar = 'A';
for (j = 1; j <= i; ++j) {
printf("%c", currentChar++);
}
printf("\n");
}
return 0;
}💡 Tips for Enhancement
Try These
- Use
for (i = 1; i <= rows; ++i)to get the growing triangle again (program 1) - Start each row from
'a'for lowercase - Omit
currentChar = 'A'each row to see a continuous alphabet across lines (different pattern) - Validate
scanfand reject invalid row counts
Avoid
- Forgetting to reset
currentCharwhen you want every row to start at A - Using
i++on the outer loop when you need the width to shrink - Confusing “row number” with loop variable
iwhen reading traces
Key Takeaways
i from rows down to 1 gives decreasing line lengths.
Reset currentChar to 'A' before printing each line so prefixes stay A, AB, ABC, …
Same total work as program 1: O(n²) characters for n rows.
Mirrors inverted star pattern 2 logic with letters instead of *.
❓ Frequently Asked Questions
i starts at rows and counts down. The inner loop runs i times, so the first line is longest and each following line is shorter.i from 1 to rows (lines grow). Here i goes from rows to 1 (lines shrink). Inner printing from A upward is the same idea.Explore More C Alphabet Patterns!
Inverted shapes are a small loop change away from the standard triangle.
If you only change the outer loop between program 1 and program 5, you reuse the same inner “print from A for i columns” idea—a good sign your code is structured well.
12 people found this page helpful
