Two Phases
Top + mirror
A..E up, then D..A down — one widest row.

Build a full diamond by stacking the inverted V from Program 33 (A..E) and then mirroring it back (D..A). The only extra trick: start the bottom half from D so the widest row (E) is printed only once. Compare Program 31 (normal V) and Program 21 (other diamond ideas). Includes a live preview, worked C examples, edge cases, and complexity.
Top + mirror
A..E up, then D..A down — one widest row.
From Prog 33
Left n..0, right 1..n, print when i == col.
Start at n-1
Bottom half begins at D to avoid a double E.
Closed diamond
For A..E (n=4), nine rows of width 9.
End letter
Pick an end letter (A–F) and draw the diamond.
Complexity
O(n) rows × O(n) scans each.
A diamond-shaped alphabet pattern opens from a tip A down to a widest letter, then closes symmetrically back to A — two inverted-V halves sharing one middle row.
In C you reuse Program 33’s diagonal scans for both phases, and start the second outer loop at n - 1 so the widest row appears once.
It teaches composing a closed shape from a reusable row printer and skipping a duplicated center — the same composition skill used in many diamond labs.
Rows A → E.
Rows D → A.
Shared diagonal rule.
Bottom starts at D.
In short: for each i in 0..n then n-1..0, scan left n..0 and right 1..n, printing when i == col, then call printf("\n").
Given an end letter (or fixed E), print a diamond: Program 33’s inverted V through the widest letter, then the matching rows back down without repeating the middle.
// Nine rows (end = E, width 9)
// A
// B B
// C C
// D D
// E E
// D D
// C C
// B B
// A | Item | Type | Description |
|---|---|---|
end / n | char / int | End letter; n = end - 'A' (4 for E). Rows = 2n+1. |
| Printed output | text | Full diamond of width 2n+1 with letters on diagonals. |
n = end - 'A'
printRows(i from 0 to n) // top incl. widest
printRows(i from n-1 down to 0) // bottom, skip widest
printRows(i):
for j from n down to 0: // left
print (i == j ? letter[j] : " ")
for k from 1 to n: // right (skip A)
print (i == k ? letter[k] : " ")
print newline | Approach | Idea | Best for |
|---|---|---|
| Two-phase outer loops | Top 0..n + bottom (n-1)..0 with shared row printer | Matching this classic sample |
| Distance from center | Map row to letter by abs distance from middle | One outer loop; same visuals |
| Goal | Pattern |
|---|---|
| Alphabet + n | char alpha[] = "ABCDEFG..."; int n = 4; |
| Top half | for (int i = 0; i <= n; i++) print_row(...); |
| Bottom half | for (int i = n - 1; i >= 0; i--) print_row(...); |
| Left / right | j = n..0 then k = 1..n with i == col ? alpha[col] : ' ' |
| Top half only | See Program 33 |
Four roles that close the diamond without a double widest row.
topGrows to the widest letter
bottomMirrors back; skips duplicating E
diagSame cell rule as Program 33
breakEnds each full-width row
Reach for this when closing Program 33’s inverted V into a full diamond.
Reuse the same row printer; add the bottom phase.
Practice ascending then descending without a double center.
Factor print_row once and call it from both phases.
Caps the alphabet-pattern set before number patterns.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one shared Program 33 row rule plus a bottom half that starts at n - 1 is the cleanest way to close an inverted V into a diamond.
Choose an end letter from A to F and draw the diamond-shaped alphabet pattern in the browser.
Three complete C programs — fixed A–E, scanf end letter, and print_cell / print_row helpers. Click View Output to reveal sample console results.
Print nine diamond rows from tip A through widest E and back to A.
Two phases with identical inner loops; the second phase starts at D to avoid duplicating the E row.
#include <stdio.h>
int main() {
char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i, j, k;
/* Top half: A through E */
for (i = 0; i <= 4; i++) {
for (j = 4; j >= 0; j--) {
if (i == j)
printf("%c", alpha[j]);
else
printf(" ");
}
for (k = 1; k <= 4; k++) {
if (i == k)
printf("%c", alpha[k]);
else
printf(" ");
}
printf("\n");
}
/* Bottom half: D through A (avoid repeating E row) */
for (i = 3; i >= 0; i--) {
for (j = 4; j >= 0; j--) {
if (i == j)
printf("%c", alpha[j]);
else
printf(" ");
}
for (k = 1; k <= 4; k++) {
if (i == k)
printf("%c", alpha[k]);
else
printf(" ");
}
printf("\n");
}
return 0;
} The upper loop mirrors Program 33 through the widest E row. The lower loop starts at i = 3 (D) so that middle line is not printed twice.
Let the user pick the end letter (like E).
Build the top half (A..end) then mirror back (end-1..A). Check scanf and validate a single A–Z character in real apps.
#include <stdio.h>
int main() {
char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char end;
int n, i, j, k;
printf("Enter top letter (like E): ");
scanf(" %c", &end);
n = end - 'A';
for (i = 0; i <= n; i++) {
for (j = n; j >= 0; j--)
printf("%c", i == j ? alpha[j] : ' ');
for (k = 1; k <= n; k++)
printf("%c", i == k ? alpha[k] : ' ');
printf("\n");
}
for (i = n - 1; i >= 0; i--) {
for (j = n; j >= 0; j--)
printf("%c", i == j ? alpha[j] : ' ');
for (k = 1; k <= n; k++)
printf("%c", i == k ? alpha[k] : ' ');
printf("\n");
}
return 0;
} n = end - 'A' scales both phases and both halves. For end = C you get 5 rows of width 5 (2n+1).
Same diamond with shared print_cell and print_row helpers.
Often clearer: one function owns the diagonal rule; another prints a full row so both phases stay thin.
#include <stdio.h>
void print_cell(char alpha[], int row, int col) {
printf("%c", row == col ? alpha[col] : ' ');
}
void print_row(char alpha[], int n, int i) {
int j, k;
for (j = n; j >= 0; j--)
print_cell(alpha, i, j);
for (k = 1; k <= n; k++)
print_cell(alpha, i, k);
printf("\n");
}
int main() {
char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int n = 4;
int i;
for (i = 0; i <= n; i++)
print_row(alpha, n, i);
for (i = n - 1; i >= 0; i--)
print_row(alpha, n, i);
return 0;
} print_cell owns the row == col rule; print_row owns both halves. The two outer loops only decide which floors to visit.
Each row prints a left diagonal via a reverse scan (n..0) and a right diagonal via a forward scan (1..n), printing only when i == col.
Outer loop prints rows for i = 0..n — this is exactly Program 33.
Start at n - 1 (D for E) so the widest row is not duplicated.
Left has n+1 columns and right has n columns. Total rows: (n+1) + n = 2n+1 (9 for A..E).
Build the top half from A to E, then mirror back down from D to A — O(n²) time.
Trace each phase, row index, and resulting 9-column line.
| Phase | i | Letter | Printed row |
|---|---|---|---|
| Top | 0 | A | A |
| Top | 1 | B | B B |
| Top | 2 | C | C C |
| Top | 3 | D | D D |
| Top | 4 | E | E E |
| Bottom | 3 | D | D D |
| Bottom | 2 | C | C C |
| Bottom | 1 | B | B B |
| Bottom | 0 | A | A |
Width is always 2×4+1 = 9. Total rows are 2×4+1 = 9. The widest E row appears only once (top phase).
Where this diamond alphabet pattern shows up beyond the homework prompt.
Clearest demo of building a closed shape from a reusable row.
Example: start bottom at n and watch a double E row.
Top and bottom floors mirror around the widest letter.
Example: compare row i=2 top with i=2 bottom.
Practice n = end - 'A' with an alphabet array.
Example: scale from E to H without rewriting loops.
Factor print_cell + print_row (Example 3).
Example: call print_row from both phases only.
2n+1 rows × width 2n+1 makes O(n²) easy to see.
Example: 9 rows × 9 cells = 81 writes for A..E.
Top half is Program 33; bottom half closes the diamond.
Example: revisit Program 33.
Pro Tip: say “print Program 33, then floors (n-1)..0 with the same row” before coding — that story prevents a duplicated widest row.
Why this pattern earns a spot as the alphabet-pattern series finale.
A double widest row or broken diagonal shows up immediately.
No new cell rule — only a second outer phase.
Change n and the whole diamond grows.
print_row keeps both phases short and readable.
Pro Tip: master Program 33 first; this page is mostly “call that row again while climbing down from n-1.”
Small habits that keep diamond alphabet patterns clean.
Starting at n duplicates the widest row.
Same tip rule as Program 33 on every row.
Use n = end - 'A' so scaling stays automatic.
scanfRequire a single A–Z character; use toupper if needed.
print_row When ReadyDuplicated left/right loops across two phases are a strong helper signal.
Pro Tip: if two identical widest rows appear, the bottom half almost certainly started at i = n.
Mistakes that commonly break diamond alphabet patterns.
Duplicates the widest row.
→ Start the bottom phase at i = n - 1.
Duplicates the tip A on tip rows.
→ Start the right scan at k = 1.
Writing only letters collapses the diamond.
→ Print a space whenever row != col.
scanfEmpty or multi-character input leaves end unused or only takes the first char.
→ Check scanf’s return value and require a single A–Z letter.
Stopping after the first loop leaves only Program 33’s inverted V.
→ Add for (i = n - 1; i >= 0; i--) with the same row printer.
Check these inputs before calling the solution done.
Output is just A (bottom half empty).
9 rows × width 9 through the E middle.
5 rows × width 5 (Example 2).
Convert lowercase with toupper from <ctype.h> if needed.
Check scanf’s return value before using end.
Temporarily print . instead of spaces.
Try these variations to lock in the pattern.
print_rowprint_row from both phasesi == col is identical to Program 33.2n + 1 (9 for A..E).Quick Takeaway: print Program 33’s rows through the widest letter, then the same rows from n-1 down to 0, with one shared diagonal rule.
| Program | Time | Extra space |
|---|---|---|
| Inline / input (Examples 1–2) | O(n²) | O(1) (plus alphabet source) |
| Helper functions (Example 3) | O(n²) | O(1) |
For n+1 letters there are 2n+1 rows and each row scans O(n) columns, so total work is O(n²).
The diamond-shaped alphabet pattern is Program 33 closed into a diamond: the same diagonal row rule, plus a bottom phase that starts at n-1 so the widest row appears once. Master the classic A…E…A sample, then try user input and the helper rewrite.
Practice the three examples above, then continue to C number pattern programs.
Top 0..n, bottom (n-1)..0, same left/right diagonal scans, then break each line.
i = n - 1k = 1i == col diagonal rule on both halvesn from the end letterprintf("\n") inside either half loopPrint the diamond-shaped alphabet pattern the beginner-friendly way.
Two phases + diagonals
Definitioni == col
CodeStart at n-1
Code2n+1 total
ShapeO(n²) time
AnalysisTwo phases with identical inner loops. Phase 1 prints A..E using two diagonal scans (left: E..A, right: B..E). Phase 2 prints D..A to mirror the top without repeating the widest E row. For n letters, total rows are 2n-1 and width is also 2n-1.
You finished the alphabet pattern series. Next up: nested-loop number patterns with the same tutorial style.
12 people found this page helpful