logoStarPatterns
Back to Patterns

Alphabet B Pattern

Pattern Result

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

Code Implementation

Explanation

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