Back to Patterns
Arrow Pattern
Pattern Result
*****************************
Code Implementation
Explanation
The Arrow Pattern creates a shape that resembles an arrow pointing upward using asterisks. The pattern consists of two parts: the arrow head (a pyramid) and the arrow shaft (a vertical line). The algorithm ensures that n is odd to create a symmetrical arrow. The arrow head is created using a pyramid pattern, where each row has an increasing number of stars centered in the row. The arrow shaft is created by placing a single star in the middle of each row for the bottom half of the pattern. The outer loops handle the arrow head and shaft separately, while the inner loops handle the spaces and stars in each row.