Shape Rule
Repeats grow
One letter per row; count is 1, 2, 3, …

Row 1 is one A, row 2 is two Bs, row 3 three Cs, and so on: A, BB, CCC, DDDD, EEEEE. Contrast Program 1, where letters change inside each row. Here, the row letter stays the same and only the count grows. Next up: Program 10 reverses the letter order. Includes a live preview, worked C examples, edge cases, and complexity.
Repeats grow
One letter per row; count is 1, 2, 3, …
Row letter
i picks A, B, C, … for each row.
Count only
Runs 1..row times but always prints i.
Print i
Same loop bounds; print i not j.
Rows 1–10
Pick a row count and draw A, BB, CCC live.
Complexity
1+2+…+n printed characters total.
A repeating-letter alphabet triangle grows like any right-angled triangle, but each row is filled with one repeated character that advances with the row number.
In C the outer loop chooses the letter and the inner loop only decides how many times to write it — print i, never the inner counter.
It teaches the classic nested-loop lesson: the inner counter can control count while the outer variable controls value — a one-character change from Program 1.
i from A to top.
j from A to i (count).
Always print i.
A, BB, CCC, …
In short: for each letter i from 'A' to top, print i once for each step of j from 'A' to i, then call printf("\n").
Given a row count (or fixed top E), print a right-angled triangle where row k repeats the k-th letter of the alphabet k times.
// Five rows (top = E)
// A
// BB
// CCC
// DDDD
// EEEEE | Item | Type | Description |
|---|---|---|
rows / top | int / char | Number of rows; last letter is 'A' + rows - 1 (E for 5). |
| Printed output | text | Growing rows of repeated letters A, BB, CCC, … |
for i from 'A' to top: // choose the row letter
for j from 'A' to i: // count = row length
print i // NOT j
print newline | Approach | Idea | Best for |
|---|---|---|
| Char nested loops | Outer i++, inner count, print i | Matching this classic sample |
| Row index + char math | ch = (char)('A' + row - 1) then print row times | User-input versions; clearer count |
| Goal | Pattern |
|---|---|
| Fixed A–E | for (char i = 'A'; i <= 'E'; i++) |
| Repeat count | for (char j = 'A'; j <= i; j++) printf("%c", i); |
| User rows | char ch = (char)('A' + row - 1); then print ch row times |
| Stepping letters | See Program 1 (print j instead) |
| Reverse letters | See Program 10 (E, DD, CCC, …) |
Same growing widths — different what you print inside the row.
print jA, AB, ABC — letters step
print iA, BB, CCC — letters repeat
print i reverseE, DD, CCC — reverse order
breakEnds the row after the repeats
Reach for this when teaching that the inner loop can control count while the outer variable controls the printed value.
Keep the same loop bounds; change only printing j to printing i.
Practice decoupling “what to print” from “how many times.”
Next keeps repeats but walks the letter backward: E, DD, CCC.
Map row numbers to letters with 'A' + row - 1.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: printing the outer letter inside the inner loop is the cleanest way to build a growing triangle of repeated characters.
Choose 1–10 rows and draw the repeating-letter alphabet triangle in the browser.
Three complete C programs — fixed A–E, user-chosen row count, and a spaced-letter variant. Click View Output to reveal sample console results.
Print five growing rows of repeated letters from A to E.
EThe inner loop runs the correct number of times, but always prints i (the row letter).
#include <stdio.h>
int main() {
char i, j;
for (i = 'A'; i <= 'E'; i++) {
for (j = 'A'; j <= i; j++) {
printf("%c", i);
}
printf("\n");
}
return 0;
} When i = 'C', the inner loop runs three times and prints C each time → CCC. Printing j instead would produce ABC on that row.
Let the user choose how many rows to print.
Compute the row letter from the row number. Check scanf in real apps, and keep rows within 26 for A–Z.
#include <stdio.h>
int main() {
int rows, row, col;
char ch;
printf("Enter the number of rows: ");
scanf("%d", &rows);
for (row = 1; row <= rows; row++) {
ch = (char)('A' + row - 1);
for (col = 1; col <= row; col++) {
printf("%c", ch);
}
printf("\n");
}
return 0;
} For row 4, ch becomes 'D' and the inner loop prints it four times. Cap rows at 26 so ch 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 = 'A'; j <= i; j++) {
printf("%c ", i);
}
printf("\n");
}
return 0;
} Loop bounds and the print-i rule are unchanged — only the printed unit becomes i + " ". Trim trailing spaces later if you need a compact line.
i runs from 'A' to top. That’s the character printed on the row.
j runs from 'A' to i, so it executes 1, 2, 3, … times as rows grow.
Printing i keeps the whole row the same letter. Printing j would change letters across the row (Program 1).
printf("\n") ends each row before the next letter begins.
Total prints are 1+2+…+n for n rows, so time complexity is O(n²).
Trace each row letter, how many times the inner loop runs, and the printed line.
i (letter) | Inner runs | Printed row |
|---|---|---|
A | 1 | A |
B | 2 | BB |
C | 3 | CCC |
D | 4 | DDDD |
E | 5 | EEEEE |
Row lengths are 1, 2, 3, 4, 5. Every character on a row matches that row’s letter.
Where this repeating-letter alphabet triangle shows up beyond the homework prompt.
Clearest demo of printing the outer variable inside the inner loop.
Example: change printing i to printing j and compare with Program 1.
Build intuition for loops that only control iteration count.
Example: rewrite the inner loop as for (int k = 0; k < n; k++).
Map row indexes to letters with 'A' + row - 1.
Example: scale from 5 to 8 without rewriting loops.
Later rewrite as new string(ch, row) once the idea clicks.
Example: same output with one print per row.
Triangle sums make O(n²) easy to see.
Example: 15 letters for 5 rows.
Sits between Programs 8 and 10 in the alphabet set.
Example: revisit Program 1.
Pro Tip: say “pick the letter outside, repeat it inside” before coding — that story prevents printing j by habit.
Why this pattern earns a spot early in the alphabet-pattern series.
A stepping-letter row (ABC) shows immediately if you printed j.
Only the printed variable changes.
Change the top letter or row count and the whole triangle grows.
No padding or diagonal checks — just two loops and one print rule.
Pro Tip: master Program 1 first; this page is mostly “same loops, print the outer letter.”
Small habits that keep repeating-letter alphabet triangles clean.
Printing j turns this into Program 1.
Do not increment the character inside the inner loop.
Keep the row letter inside A–Z when taking user input.
scanfValidate the row count and check scanf’s return value.
Use ch = (char)('A' + row - 1) when working with integer row indexes.
Pro Tip: if you see A, AB, ABC, you printed j — switch back to printf("%c", i).
Mistakes that commonly break repeating-letter alphabet triangles.
Produces Program 1 (A, AB, ABC) instead of A, BB, CCC.
→ Use printf("%c", i) (or ch) inside the inner loop.
Changes the character mid-row and breaks the uniform look.
→ Keep the letter fixed for the whole row.
Using 'A' + row without - 1 starts at B.
→ Use ch = (char)('A' + row - 1).
scanfEmpty or non-numeric input leaves rows 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 EEEEE (Example 1).
Ends at DDDD (Example 2).
Cap or reject — the row letter leaves the alphabet.
Check scanf’s return value.
Swap 'A' for 'a' as the base.
Try these variations to lock in the pattern.
i to printing jnew string(ch, row)i (not j) is what keeps each row uniform.Quick Takeaway: choose the row letter in the outer loop, then print that letter once per inner iteration — that alone builds A, BB, CCC, …
| 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 repeating-letter alphabet triangle is Program 1 with a different print rule: the outer loop picks the letter, and the inner loop only repeats it. Master the classic A…EEEEE sample, then try user input and the spaced rewrite.
Practice the three examples above, then continue to Alphabet Pattern 10.
Outer i from A to top, inner count from A to i, print i each time, then break each line.
i or ch) inside the inner loopch = (char)('A' + row - 1) for integer row indexesj when you want A, BB, CCC- 1 in the letter formulaprintf("\n") inside the letter loopPrint the repeating-letter alphabet triangle the beginner-friendly way.
One letter, growing repeats
DefinitionPrint i, not j
Controls count only
ShapeSame loops, different print
CompareO(n²) time
AnalysisEach row prints the same letter repeatedly: row 1 prints A once, row 2 prints B twice, row 3 prints C three times, and so on. The key is to print the outer loop letter inside the inner loop.
A one-line change inside the inner loop can switch between repeating letters and stepping letters.
12 people found this page helpful