Alphabet G Pattern
Pattern Result
****** **** ***** ******
Code Implementation
Explanation
The Alphabet G Pattern creates a shape that resembles the letter G using asterisks. The pattern consists of six parts: the top curved part, the top-middle part, the upper vertical part, the middle part with a horizontal line, the lower vertical part, and the bottom curved part. The algorithm ensures that n is odd to create a symmetrical G. 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 lower vertical parts are created by placing stars at the first and last positions, with spaces in between. The upper vertical part is created by placing a star only at the first position, with spaces filling the rest of the row. The middle part includes a horizontal line extending from the middle to the right side of the pattern.