An inverted forward repeating alphabet triangle shrinks in width each row while the letter advances: row 1 is all As, row 2 all Bs, and so on.
Remember
Rule: width i from rows down to 1;
print ch exactly i times, then ch++
AAAAA
BBBB
CCC
DD
E ← 5 rows (start ch = 'A')
Same inverted widths as Program 11, but letters count up with ch++ instead of down. Print ch in the inner loop, then ch++ after each row so every line stays uniform.
Approach
How to Solve It
Two ways to emit the same shape — start with nested loops + ch++, then optionally polish with putchar.
Method
Idea
Best for
Nested loops + ch++
Outer = shrinking width; print ch, then increment
Learning, interviews, exams
putchar(ch)
Same loops; write each letter without a format string
Shorter demos once loops click
Pseudocode
Pseudocode
ch = 'A'
for i from rows down to 1:
for j from 1 to i:
print ch (no newline)
print newline
ch = ch + 1
Print characters without a newline, then end the row once.
Try it
Live Preview
Change the height and the inverted forward triangle updates instantly — including the letter total.
Whole numbers from 1 to 26 (A–Z). Tap a chip or type a value — the preview redraws as you go.
Live result5 rows · 15 letters
AAAAA
BBBB
CCC
DD
E
Trace
Worked Walkthrough — rows = 5, start ch = 'A'
Trace each outer-loop width i and the letter printed on that row.
i (width)
ch
Printed row
Then
5
'A'
AAAAA
ch++ → 'B'
4
'B'
BBBB
ch++ → 'C'
3
'C'
CCC
ch++ → 'D'
2
'D'
DD
ch++ → 'E'
1
'E'
E
done
Total letter prints: 5 + 4 + 3 + 2 + 1 = 15 = 5×6/2. That triangular sum is why time is O(n²).
Code
C Programs
Three complete programs: fixed letters, scanf input, and a putchar variant. Use View Output to reveal sample results.
Example 1 — Fixed 'A' up through 'E'
Hard-coded height — outer width shrinks; print ch, then ch++ after each row.
C
#include <stdio.h>
int main(void)
{
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;
}
Output
AAAAA
BBBB
CCC
DD
E
How It Works
1. Start at A.ch = 'A' and i = 5 mean the first row is five As.
2. Outer loop shrinks the width.i runs from 5 down to 1.
3. Inner loop prints ch.j runs from 1 to i; each time prints the current letter (not j).
4. Break the line, then step the letter.printf("\n") ends the row; ch++ prepares B, C, … for the next shorter row.
Example 2 — User Input Version
Keep ch = 'A'; loop i from rows down to 1. Check scanf in real apps.
C
#include <stdio.h>
int main(void)
{
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;
}
Output (when user enters 4)
Enter the number of rows: 4
AAAA
BBB
CC
D
How It Works
1. Prompt and read. Ask for a row count with scanf("%d", &rows).
2. Always start at A. For rows = 4, the first row is AAAA, then BBB, up to a single D.
3. Same shrink core. Only the source of rows changes — the print logic matches Example 1.
Total letters = n + (n - 1) + … + 1 = n(n + 1)/2 — still quadratic in n. Same totals as Program 11; only the letter direction differs.
Remember
Key Takeaways
Rule: shrink width i; print ch exactly i times; then ch++.
Twin of Program 11: same widths — letters advance A→E instead of counting down.
Break the row:printf("\n") (or putchar('\n')) only after the inner loop.
Complexity:O(n²) time from the triangular letter count; O(1) extra space.
One line: start at 'A'; for i from rows down to 1, print chi times, print newline, then ch++.
Frequently Asked Questions
Program 11 prints EEEEE, DDDD, ... (letters step down with ch--). Program 12 prints AAAAA, BBBB, ... (letters step up with ch++) with the same inverted widths 5..1.
i starts at 5 so the first inner loop runs five times while ch is A. After the row, ch becomes B and i is 4, so the next line prints B four times.
So every column on a row shows the same letter. Incrementing inside the inner loop would step letters across the row.
j only controls how many times the loop runs. Printing ch keeps the entire row the same letter; printing j would step letters across the row.
printf("%c", ch) prints a letter and stays on the same line. printf("\n") ends the current line. Letters use %c; the row break uses \n after the inner loop.
O(n²) where n is the number of rows. Total letter prints equal n+(n-1)+…+1 = n(n+1)/2.
Yes. putchar(ch) writes one character without a format string. Nested loops with putchar are a common, slightly leaner style.
Check scanf's return value: if (scanf("%d", &rows) != 1) handle bad input. Keep ch = 'A' and loop i from rows down to 1 with ch++ after each row. Clamp to 26 for A–Z demos.
🤔
Did you know?
This is the forward-letter twin of Program 11: same inverted widths (5…1), but letters advance A→E with ch++ instead of stepping down. Print ch in the inner loop, then ch++ after each row so every line stays uniform.