Shape Rule
Left grows
Highest letter A → E; row length grows 1..n.

Print a right-angled triangle where the first character of each row moves forward (A, B, C, D, E), but each row prints letters in reverse order down to A: A, BA, CBA, DCBA, EDCBA. Compare with Program 1 (forward along each row) and Program 3 (reverse starting letter, forward along row). Includes a live preview, worked C examples, edge cases, and complexity.
Left grows
Highest letter A → E; row length grows 1..n.
j-- to A
Print from the row’s peak letter down to A.
Always A
Every row ends at A — a vertical right edge.
Direction
Same growth; letters run backward, not forward.
Rows 1–10
Pick a row count and draw BA / CBA / … live.
Complexity
1+2+…+n printed characters total.
A reverse-order alphabet triangle grows like Program 1, but each row prints its letters descending to A instead of ascending from A.
In C you raise the peak letter with the outer loop (i++) and count down with the inner loop (j--) until you hit 'A'.
It shows how flipping only the inner loop direction turns A, AB, ABC into A, BA, CBA — a classic nested-loop direction drill.
i from A to top.
j from i down to A.
Every row ends at A.
A, BA, CBA, …
In short: for each peak letter i from 'A' to top, print j from i down to 'A', then call printf("\n").
Given a row count (or fixed top E), print a right-angled triangle where each row starts at a higher letter and counts down to A.
// Five rows (top = E)
// A
// BA
// CBA
// DCBA
// EDCBA | Item | Type | Description |
|---|---|---|
rows / top | int / char | Number of rows; top letter is 'A' + rows - 1 (E for 5). |
| Printed output | text | Growing reverse-order lines ending at A on every row. |
top = 'A' + rows - 1
for i from 'A' to top: // peak letter grows
for j from i down to 'A': // reverse along the row
print j
print newline | Approach | Idea | Best for |
|---|---|---|
| Char nested loops | Outer i++, inner j-- to A | Matching this classic sample |
| Index + alphabet array | Print alpha[k] for k = i..0 | When you already use string indexes |
Same growing triangle — different letter direction and edges.
A..iForward from A; left edge fixed
i..topForward to top; right edge fixed
i..ABackward to A; right edge fixed
breakEnds the row after the descent
Reach for this when teaching a growing peak letter with a descending letter run.
Keep the triangle; flip only the inner loop to j--.
Practice prefixes that always end at the same letter (A).
Both fix one edge; this one fixes A on the right with a reverse run.
Mix i++ with j-- in the same program.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one growing peak plus a descending inner loop is the cleanest way to keep a fixed A on the right while rows grow.
Choose 1–10 rows and draw the reverse-order alphabet triangle in the browser.
Three complete C programs — fixed A–E, scanf row count, and a spaced-letter variant. Click View Output to reveal sample console results.
Print five rows with a growing peak and a reverse letter run.
EOuter loop picks the highest letter on each row; inner loop prints from that letter down to 'A'.
#include <stdio.h>
int main() {
char i, j;
for (i = 'A'; i <= 'E'; i++) {
for (j = i; j >= 'A'; j--) {
printf("%c", j);
}
printf("\n");
}
return 0;
} When i = 'C', the inner loop prints C, B, A → CBA. When i = 'E', it prints the full reverse run EDCBA.
Let the user choose how many rows to print.
Read the number of rows and loop i from 'A' to 'A' + rows - 1. Check scanf in real apps.
#include <stdio.h>
int main() {
int rows;
char i, j;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (i = 'A'; i < 'A' + rows; i++) {
for (j = i; j >= 'A'; j--) {
printf("%c", j);
}
printf("\n");
}
return 0;
} For 4 rows, i runs through A..D. Cap rows at 26 so the peak letter stays within A–Z.
Same triangle with spaces between letters.
Print a trailing space after each letter so columns are easier to scan.
#include <stdio.h>
int main() {
char i, j;
for (i = 'A'; i <= 'E'; i++) {
for (j = i; j >= 'A'; j--) {
printf("%c ", j);
}
printf("\n");
}
return 0;
} Loop bounds are unchanged — only the printed unit becomes j + " ". Trim trailing spaces later if you need a compact line.
i runs from 'A' to top. Row length grows because later rows start at a higher letter.
For each row, j starts at i and counts down to 'A'. Printing j produces BA, CBA, DCBA, and so on.
printf("\n") ends the row and moves to the next line.
Because the inner loop always stops at 'A', every row ends on A while the left side grows.
Total printed characters are 1+2+…+n, so time complexity is O(n²).
Trace each peak letter and the resulting reverse run down to A.
i (peak) | Inner range | Printed row |
|---|---|---|
A | A..A | A |
B | B..A | BA |
C | C..A | CBA |
D | D..A | DCBA |
E | E..A | EDCBA |
Row lengths are 1, 2, 3, 4, 5. The right edge is always A.
Where this reverse-order alphabet triangle shows up beyond the homework prompt.
Clearest demo of flipping only the inner loop.
Example: change j-- to j++ and compare with Program 1.
Fixed right edge (A) with a growing left edge.
Example: stack next to Program 3’s fixed E edge.
Practice inclusive descending ranges ending at 'A'.
Example: off-by-one if you stop at 'B'.
Map row count to peak letter with 'A' + rows - 1.
Example: scale from 5 to 8 without rewriting loops.
Triangle sums make O(n²) easy to see.
Example: 15 letters for 5 rows.
Sits between Programs 3 and 5 in the alphabet set.
Example: revisit Program 1.
Pro Tip: say “raise the peak, then walk down to A” before coding — that story prevents writing a forward inner loop by habit.
Why this pattern earns a spot early in the alphabet-pattern series.
A forward row or missing A shows up immediately.
Only the inner step direction changes.
Change the top letter or row count and the whole triangle grows.
No padding or diagonal checks — just two char loops.
Pro Tip: master Program 1 first; this page is mostly “same outer loop, count down instead of up.”
Small habits that keep reverse-order alphabet triangles clean.
Use j >= 'A' so every row still ends with A.
Starting at a fixed letter breaks the growing left edge.
Keep the peak letter inside A–Z when taking user input.
scanfValidate the row count and check scanf’s return value.
Same outer loop; only j++ vs j-- differs.
Pro Tip: if you see A, AB, ABC, the inner loop is still incrementing — switch to j--.
Mistakes that commonly break reverse-order alphabet triangles.
Prints Program 1 instead of BA / CBA.
→ Use for (char j = i; j >= 'A'; j--).
Using j > 'A' drops the trailing A on every row.
→ Keep the condition inclusive: j >= 'A'.
'A' + rows - 1 can leave the alphabet.
→ Cap rows at 26 (or handle wrap explicitly).
scanfEmpty or non-numeric input leaves rows unused or uninitialized.
→ Check scanf’s return value and validate range.
printf("\n")All letters dump onto one line.
→ Call printf("\n") after each inner loop.
Check these inputs before calling the solution done.
Output is just A.
A through EDCBA (Example 1).
Ends at DCBA (Example 2).
Cap or reject — peak leaves the alphabet.
Check scanf’s return value.
Swap 'A' for 'a' in both loops.
Try these variations to lock in the pattern.
j++i++ raises the first letter of each row.'A', so the right edge is vertical.Quick Takeaway: raise the peak letter with the outer loop, then walk down to A with the inner loop — that alone builds A, BA, CBA, …
| Program | Time | Extra space |
|---|---|---|
| Inline / input (Examples 1–2) | O(n²) | O(1) |
| Spaced letters (Example 3) | O(n²) | O(1) |
For n rows you print 1+2+…+n = n(n+1)/2 characters, so total work is O(n²).
The reverse-order alphabet triangle is Program 1 with a descending inner loop: the peak letter grows A…E while each row walks back down to A. Master the classic A…EDCBA sample, then try user input and the spaced rewrite.
Practice the three examples above, then continue to Alphabet Pattern 5.
Outer i from A to top, inner j from i down to A, then break each line.
i and count down to 'A'j >= 'A' inclusivej++ when you want BA / CBA'A''A' + rows go past 'Z'printf("\n") inside the letter loopPrint the reverse-order alphabet triangle the beginner-friendly way.
Peak grows, letters descend
Definitionj from i to A
CodeEvery row ends at A
ShapeOnly direction flips
CompareO(n²) time
AnalysisEach row starts one letter later (A, B, C, …), but prints backward down to A. For 5 rows, the output is A, BA, CBA, DCBA, EDCBA.
Small changes in loop direction completely change the output — keep experimenting.
12 people found this page helpful