Symmetric Alphabet, Star Center

What You’ll Learn
Build rows that read the same forwards and backwards on the letters, with * filling the gap in the middle as the row shortens.
The classic reference form uses ASCII values (65.. 69) and prints \"**\" pairs in the middle to keep symmetry.
⭐ Pattern Output
For n = 5:
ABCDEEDCBA
ABCD**DCBA
ABC****CBA
AB******BA
A********AComplete C++ Program (Reference Logic)
Three zones per row: left letters, star gap, right letters. The star loop prints \"**\" (two stars) per iteration, so the center width grows by 2 each row.
#include <iostream>
using namespace std;
int main() {
int i, j, k, m;
for (i = 69; i >= 65; i--) {
for (j = 65; j <= i; j++)
cout << (char) j;
for (k = i; k < 69; k++)
cout << \"**\";
for (m = i; m >= 65; m--)
cout << (char) m;
cout << \"\\n\";
}
return 0;
}🧠 How It Works
Outer i = 'E' .. 'A'
The end letter shrinks each row: E, D, C, B, A.
Left half j = 'A' .. i
Print a prefix from A up to the current row end letter.
Star gap \"**\"
The loop runs 69 - i times and prints two stars per step, so stars = 2*(69 - i).
Right half m = i .. 'A'
Mirror the left side by printing descending letters.
Characters per row
For n = 5, each row prints 10 characters total (letters + stars + letters).
Variation — User Input (General n)
Use top = base + rows - 1. The star count becomes 2*(top - i), so it grows by 2 each row as the letter range shrinks.
#include <iostream>
using namespace std;
int main() {
int rows;
int i, j, k, m;
const int base = 65;
cout << \"Enter the number of rows: \";
cin >> rows;
int top = base + rows - 1;
for (i = top; i >= base; i--) {
for (j = base; j <= i; j++)
cout << (char) j;
for (k = i; k < top; k++)
cout << \"**\";
for (m = i; m >= base; m--)
cout << (char) m;
cout << \"\\n\";
}
return 0;
}💡 Tips for Enhancement
Try These
- Swap
*for spaces or.for a softer look - Trace one row: track the last printed letter and the star count
2*(top - i) - Clamp
rowssotopstays within'A'..'Z'
Avoid
- Printing
\"*\"once per iteration if you want the exact reference output (it uses\"**\") - Using
2 * ifor stars instead of2 * (top - i)(center width flips)
Key Takeaways
Three zones per row: ascending letters, stars, descending letters.
The middle grows by 2 stars each row: 2*(top - i).
For fixed n, each row prints 2n total characters in this pattern family.
Overall time O(n²) for n rows.
❓ Frequently Asked Questions
i == top, the gap is 2*(top - i) = 0. The two halves meet directly: ABCDE + EDCBA.rows >= 1.Explore More C++ Alphabet Patterns!
Mixing letters and stars is the same idea as hollow or diamond star programs — split each row into zones.
For fixed n, each row prints exactly 2n characters total (letters + stars + letters). That makes it easy to center-align the pattern in monospaced output if you want to extend it.
12 people found this page helpful
