Back to Patterns
Square Hollow Pattern
Pattern Result
* * * * ** ** ** ** * * * *
Code Implementation
Explanation
The Square Hollow Pattern creates a square shape using asterisks (*) where only the border is visible. The algorithm uses nested loops to iterate through each row and column. It places an asterisk only when the current position is on the first or last row, or on the first or last column. For all other positions, it adds spaces to create the hollow effect.