logoStarPatterns
Back to Patterns

Alphabet C Pattern

Pattern Result

******
* *
*
*
*
* *
******

Code Implementation

Explanation

The Alphabet C Pattern creates a shape that resembles the letter C using asterisks. The pattern consists of five parts: the top curved part, the top-middle part, the middle part, the bottom-middle part, and the bottom curved part. The algorithm ensures that n is odd to create a symmetrical C. The top and bottom curved parts are created by placing spaces at the first and last positions, with stars in between. The top-middle and bottom-middle parts are created by placing stars at the first and last positions, with spaces in between. The middle part is created by placing a star only at the first position, with spaces filling the rest of the row.