Symmetric Alphabet, Star Center in C#

What You’ll Learn
Build rows that read the same on letters from both ends, while * fills the center gap as the row shortens.
For top = 'E', the output begins with ABCDEEDCBA and ends with A********A.
⭐ Pattern Output
For 5 rows:
ABCDEEDCBA
ABCD**DCBA
ABC****CBA
AB******BA
A********AComplete C# Program (Five Rows)
Three parts per row: left letters (A..i), stars (2*(top-i)), then right letters (i..A).
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
char top = 'E';
for (char i = top; i >= 'A'; i--)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
int stars = 2 * (top - i);
for (int s = 1; s <= stars; s++)
{
Console.Write("*");
}
for (char m = i; m >= 'A'; m--)
{
Console.Write(m);
}
Console.WriteLine();
}
}
}
}🧠 How It Works
Outer loop picks row end
The row end letter i goes from E down to A.
Left half prints A..i
That gives ABCDE, then ABCD, then ABC, etc.
Stars fill the center gap
Star count is 2 * (top - i): 0, 2, 4, 6, 8.
Mirrored right half
Finally, print i..A to mirror the left side.
Variation — User Input Version
Read rows, compute top, then reuse the same idea. (If rows > 26, you will go beyond Z.)
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
char top = (char)('A' + rows - 1);
for (char i = top; i >= 'A'; i--)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
int stars = 2 * (top - i);
for (int s = 1; s <= stars; s++)
{
Console.Write("*");
}
for (char m = i; m >= 'A'; m--)
{
Console.Write(m);
}
Console.WriteLine();
}
}
}
}💡 Tips for Enhancement
Try These
- Replace
*with another symbol (like#) - Add a space between characters if you want a wider output
- Compare with star patterns (same center-gap idea)
- Cap rows at 26 to stay inside A–Z
Avoid
- Forgetting the mirror half (you’ll lose symmetry)
- Using an incorrect star count (it must be even for this output)
- Printing the left half in reverse (that changes the pattern)
Key Takeaways
Row end letter moves from top down to A.
Left prints A..end; right prints end..A.
Stars fill the middle as 2*(top-end).
Time complexity is O(n²).
❓ Frequently Asked Questions
2*(top - i), which is always a multiple of 2.(char)(i - 1) instead of i when there are zero stars.Explore More C# Alphabet Patterns!
Center gaps (stars/spaces) are a classic trick for symmetric patterns.
On each row, the total output width stays constant: left letters \(+\) stars \(+\) right letters \(=\) \(2n\) characters for \(n\) rows (here \(2 \times 5 = 10\)).
12 people found this page helpful
