Inverted Forward Repeating Triangle in C

What You’ll Learn
Row width shrinks from five to one, but the letter moves forward each row: AAAAA, BBBB, CCC, DD, E.
Compare program 11 (same shape, letters step down with ch--) and program 9 (width grows with ch++).
⭐ Pattern Output
For 5 rows:
AAAAA
BBBB
CCC
DD
EComplete C Program (Fixed Rows)
i controls width (5 down to 1). ch starts at 'A'; after each full row, move to the next letter with ch++.
#include <stdio.h>
int main() {
int i, j;
char ch = 'A';
for (i = 5; i >= 1; --i) {
for (j = 1; j <= i; ++j) {
printf("%c", ch);
}
printf("\n");
ch++;
}
return 0;
}🧠 How It Works
ch = 'A'
The widest row starts at A. Unlike program 11, the letter moves forward (ch++) as the rows get shorter, so you read AAAAA, BBBB, … down to one E.
Outer loop i = 5 .. 1
Decreasing i shrinks the row width each time while you still print a single repeated letter per row. Geometry matches an inverted triangle of repeats.
Inner loop: uniform row
The inner index only controls the count. Each printf("%c", ch) uses the same ch for that row, so you never mix letters on one line.
New line, then ch++
After each row, a newline resets the cursor. Incrementing ch picks the next letter for the shorter row that follows.
Count and complexity
Again 5+4+3+2+1 characters. In general n(n+1)/2 prints for n starting width, so the nested loops are O(n²).
Variation — User Input Version
Keep ch = 'A'; only the outer bounds use rows (same logic as the fixed version).
#include <stdio.h>
int main() {
int rows, i, j;
char ch = 'A';
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (i = rows; i >= 1; --i) {
for (j = 1; j <= i; ++j) {
printf("%c", ch);
}
printf("\n");
ch++;
}
return 0;
}💡 Tips for Enhancement
Try These
- Stateless form:
ch = (char)('A' + rows - i)at the top of each outer iteration (noch++variable) - Reverse letters on the same shape: program 11
- Validate
rowssochdoes not pass'Z'if you extend the idea
Avoid
ch++inside the inner loop unless you want a diagonal staircase- Skipping
ch++so every row staysA
Key Takeaways
Inverted width (5→1) plus ch++ after each row gives forward letters on a shrinking triangle.
ch++ once per row keeps each line uniform.
O(n²) characters for n rows.
Dual of program 11; same structure as program 9 with the outer loop reversed.
❓ Frequently Asked Questions
i starts at 5, so the inner loop runs five times while ch is still 'A'.printf("\n") matches program 9’s style.ch = 'A', then for (i = rows; i >= 1; --i) with the same inner loop and ch++ after each row.Explore More C Alphabet Patterns!
Inverted triangle plus forward letters is a small change from program 11 with a different feel.
With rows fixed, you can set ch = (char)('A' + rows - i) at the start of each outer iteration while i runs rows down to 1—no ch++ variable needed.
12 people found this page helpful
