An inverted repeating alphabet triangle prints a wide first row of one letter, then shrinks by one repeated letter on each new line while letters count down.
Remember
Rule: width i from rows down to 1;
print ch exactly i times, then ch--
EEEEE
DDDD
CCC
BB
A ← 5 rows (start ch = 'E')
It is the flip of Program 10: same countdown letters, but widths shrink 5, 4, 3, …, 1 instead of growing. 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 decrement
Learning, interviews, exams
putchar(ch)
Same loops; write each letter without a format string
Shorter demos once loops click
Pseudocode
Pseudocode
ch = 'A' + rows - 1
for i from rows down to 1:
for j from 1 to i:
print ch (no newline)
print newline
ch = ch - 1
Total letters = n + (n - 1) + … + 1 = n(n + 1)/2 — still quadratic in n. Same totals as Program 10; only the print order of widths differs.
Remember
Key Takeaways
Rule: shrink width i; print ch exactly i times; then ch--.
Flip of Program 10: same letters — widths shrink instead of grow.
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: for i from rows down to 1, print chi times, print newline, then ch--.
Frequently Asked Questions
Program 10 prints widths 1..5 (E, DD, CCC, ...). Program 11 prints widths 5..1 (EEEEE, DDDD, ...). Both use repeating letters per row and letters counting down.
i starts at 5 so the first inner loop runs five times while ch is E. After the row, ch becomes D and i is 4, so the next line prints D four times.
So every column on a row shows the same letter. Decrementing 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. Then set ch = 'A' + rows - 1 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 inverted twin of Program 10: letters still step E→A, but widths shrink 5, 4, 3, …, 1 instead of growing. Print ch in the inner loop, then ch-- after each row so every line stays uniform.