Two Phases
Upper + lower
E..A down, then B..E up — one center.

Build a full reverse-centered alphabet diamond by reusing Program 28’s row rule twice: descend the floor from E to A, then ascend from B to E so the center row is not repeated. Compare Program 21 (diamond symmetry) and Program 24 (palindrome triangles). Includes a live preview, worked C examples, edge cases, and complexity.
Upper + lower
E..A down, then B..E up — one center.
From Prog 28
Left E..A, right B..E, floor j > i.
Start at B
Lower half begins at i = 1 to avoid a double A row.
Closed diamond
For A..E, nine rows of width 9.
Top letter
Pick a top letter (A–F) and draw the full pyramid.
Complexity
O(n) rows × O(n) cells each.
A reverse centered alphabet pyramid keeps every row full width while the floor letter moves from the peak down to A at the center, then back up to the peak — a closed diamond of layered letters.
In C you reuse the same mirrored scans and j > i floor rule as Program 28, then add a second outer loop that ascends from B so the center line appears once.
It teaches two-phase outer loops, skipping a duplicated center, and composing a full shape from a reusable row printer — skills that transfer to diamonds and concentric grids.
Floor E → A.
Floor B → E.
Shared cell rule.
Lower starts at B.
In short: for each floor i in k..A then B..k, scan left k..A and right B..k, printing j > i ? j : i, then call printf("\n").
Given a top letter (or fixed E), print a reverse-centered alphabet pyramid: Program 28’s layered square, then the matching bands back up without repeating the center.
// Nine rows (space after each letter; width 9)
// E E E E E E E E E
// E D D D D D D D E
// E D C C C C C D E
// E D C B B B C D E
// E D C B A B C D E <-- center (once)
// E D C B B B C D E
// E D C C C C C D E
// E D D D D D D D E
// E E E E E E E E E | Item | Type | Description |
|---|---|---|
top / k | char / int | Top letter; k = top - 'A' (4 for E). Rows = 2k+1. |
| Printed output | text | Full reverse-centered pyramid of width 2k+1. |
k = top - 'A'
printRows(i from k down to 0) // upper incl. center
printRows(i from 1 up to k) // lower, skip A
printRows(i):
for j from k down to 0: // left half
print (j > i ? letter[j] : letter[i]) + " "
for j from 1 to k: // right half
print (j > i ? letter[j] : letter[i]) + " "
print newline | Approach | Idea | Best for |
|---|---|---|
| Two-phase outer loops | Upper k..A + lower B..k with shared row printer | Matching this classic sample |
| Single abs-distance loop | Map row to floor via distance from center | One outer loop; same visuals |
| Goal | Pattern |
|---|---|
| Top letter | char k = 'E'; (or from scanf) |
| Upper half | for (i = k; i >= 'A'; --i) print_row(...); |
| Lower half | for (i = 'B'; i <= k; ++i) print_row(...); |
| Left / right | j = k..A then j = B..k with j > i ? j : i |
| Upper only | See Program 28 |
Four roles that close the reverse-centered pyramid.
upperDescends to the A-center row
lowerAscends back; skips duplicating A
floorSame cell rule as Program 28
breakEnds each full-width row
Reach for this when closing Program 28’s square into a full reverse-centered diamond.
Reuse the same row printer; add the lower phase.
Practice descending then ascending without a double center.
Factor print_row once and call it from both phases.
Map letters to array indexes and scale with k.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one shared row rule plus a lower half that starts at B is the cleanest way to close Program 28 into a full reverse-centered pyramid.
Choose a top letter from A to F and draw the reverse centered alphabet pyramid in the browser.
Three complete C programs — fixed A–E, scanf top letter, and shared print_row helpers. Click View Output to reveal sample console results.
Print nine reverse-centered rows from E down to A and back up to E.
Same row logic as Program 28, printed in two phases to complete the reverse centered pyramid.
#include <stdio.h>
int main() {
char k = 'E';
char i, j;
/* Upper half (E down to A) */
for (i = k; i >= 'A'; --i) {
for (j = k; j >= 'A'; --j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
for (j = 'B'; j <= k; ++j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
printf("\n");
}
/* Lower half (B up to E) — skip repeating the A row */
for (i = 'B'; i <= k; ++i) {
for (j = k; j >= 'A'; --j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
for (j = 'B'; j <= k; ++j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
printf("\n");
}
return 0;
} The upper loop mirrors Program 28 through the A-center row. The lower loop starts at i = 'B' so that center line is not printed twice.
Let the user pick the top letter (like E).
Works for A..top with the same two-phase pyramid. Check scanf’s return value and require A–Z in real apps.
#include <stdio.h>
int main() {
char top, k, i, j;
printf("Enter top letter (like E): ");
scanf(" %c", &top);
k = top;
for (i = k; i >= 'A'; --i) {
for (j = k; j >= 'A'; --j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
for (j = 'B'; j <= k; ++j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
printf("\n");
}
for (i = 'B'; i <= k; ++i) {
for (j = k; j >= 'A'; --j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
for (j = 'B'; j <= k; ++j) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
printf("\n");
}
return 0;
} k = top scales both phases and both halves. For top = C you get 5 rows of width 5 (2*(top-'A')+1).
Same shape with shared print_cell and print_row helpers.
Often clearer: one function owns the floor rule; another prints a full row so both phases stay thin.
#include <stdio.h>
void print_cell(char j, char i) {
if (j > i) {
printf("%c ", j);
} else {
printf("%c ", i);
}
}
void print_row(char k, char i) {
char j;
for (j = k; j >= 'A'; --j) {
print_cell(j, i);
}
for (j = 'B'; j <= k; ++j) {
print_cell(j, i);
}
printf("\n");
}
int main() {
char k = 'E';
char i;
for (i = k; i >= 'A'; --i) {
print_row(k, i);
}
for (i = 'B'; i <= k; ++i) {
print_row(k, i);
}
return 0;
} print_cell owns the j > i rule; print_row owns both halves. The two outer loops only decide which floors to visit.
Each row prints a left scan (E..A) and a right scan (B..E). Each cell prints j when j > i, otherwise prints i.
Run i = k..'A' (E to A) to reach the center row with A — this is Program 28.
Start the second loop at B (i = 1) to avoid printing the center line twice.
Left half has k+1 letters and right half has k letters, so total width is 2k+1. Every row stays aligned.
Print down to the center (A row), then the matching bands back up — O(n²) time for n letters.
Trace each floor and the resulting 9-letter line across both phases.
| Phase | i | Floor | Printed row |
|---|---|---|---|
| Upper | 4 | E | E E E E E E E E E |
| Upper | 3 | D | E D D D D D D D E |
| Upper | 2 | C | E D C C C C C D E |
| Upper | 1 | B | E D C B B B C D E |
| Upper | 0 | A | E D C B A B C D E |
| Lower | 1 | B | E D C B B B C D E |
| Lower | 2 | C | E D C C C C C D E |
| Lower | 3 | D | E D D D D D D D E |
| Lower | 4 | E | E E E E E E E E E |
Width is always 2×4+1 = 9. Total rows are 2×5−1 = 9. The A-center row appears only once (upper phase).
Where this reverse-centered pyramid shows up beyond the homework prompt.
Clearest demo of building a full shape from a reusable row.
Example: start lower at 0 and watch a double A row.
Upper and lower floors mirror around the center.
Example: compare row i=2 upper with i=2 lower.
Practice k = top - '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 prints for A..E.
Upper half is Program 28; lower half closes the diamond.
Example: revisit Program 28.
Pro Tip: say “print Program 28, then floors B..E with the same row” before coding — that story prevents a duplicated center A.
Why this pattern earns a spot right after the symmetric decreasing square.
A double center or broken mirror shows up immediately.
No new cell rule — only a second outer phase.
Change k and the whole diamond grows.
print_row keeps both phases short and readable.
Pro Tip: master Program 28 first; this page is mostly “call that row again while climbing from B.”
Small habits that keep reverse-centered pyramids clean.
Starting at 0 duplicates the A-center row.
Reuse j > i ? j : i on both halves of every row.
Use k = top - 'A' so scaling stays automatic.
Require a single A–Z character; normalize case if needed.
Duplicated left/right loops across two phases are a strong helper signal.
Pro Tip: if two identical A-center rows appear, the lower half almost certainly started at i = 0.
Mistakes that commonly break reverse-centered alphabet pyramids.
Duplicates the A-center row.
→ Start the lower phase at i = 1.
Duplicates the center A inside a row.
→ Start the right scan at j = 1.
Using j >= i or swapping operands changes layer borders.
→ Keep j > i ? j : i.
scanfEmpty or non-letter input leaves top invalid.
→ Check scanf’s return value and require A–Z.
Stopping after the first loop leaves only Program 28’s square.
→ Add for (i = 1; i <= k; i++) with the same row printer.
Check these inputs before calling the solution done.
Output is just A (lower half empty).
9 rows × width 9 through the A center.
5 rows × width 5 (Example 2).
Normalize with char.toupper if needed.
Unchecked scanf fails silently — check the return value.
Replace alpha with 5..1 style indexes in both phases.
Try these variations to lock in the pattern.
j > i ? j : i is identical to Program 28.2k + 1 (9 for A..E).Quick Takeaway: print Program 28’s rows down to A, then the same rows from B up to E, with one shared j > i 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 letters there are 2n−1 rows and each row prints O(n) cells (width 2n−1), so total work is O(n²).
The reverse centered alphabet pyramid is Program 28 closed into a diamond: the same mirrored row rule, plus a lower phase that starts at B so the A-center appears once. Master the classic E…A…E sample, then try user input and the helper rewrite.
Practice the three examples above, then continue to Program 30’s decreasing and increasing alphabet rows.
Upper k..A, lower B..k, same left/right scans with j > i, then break each line.
i = 1j = 1j > i floor rule on both halvesk from the top letterprintf("\n") inside either half loopPrint the reverse centered alphabet pyramid the beginner-friendly way.
Two phases + floor
Definitionj > i ? j : i
CodeStart at B
Code2n−1 total
ShapeO(n²) time
AnalysisReuse Program 28’s row logic twice: first with i from E down to A, then with i from B up to E so the center row is not duplicated. Each row stays full width (2n-1 cells); total rows are also 2n-1 for n letters.
Next up: decreasing and increasing alphabet row patterns.
12 people found this page helpful