logoStarPatterns
Back to Patterns

Alphabet Z Pattern

Pattern Result

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

Code Implementation

Explanation

The Alphabet Z Pattern creates a shape that resembles the letter Z using asterisks. The pattern consists of three parts: the top row (a horizontal line), the middle part (a diagonal line), and the bottom row (a horizontal line). The top and bottom rows are filled with stars to create the horizontal bars of the Z. The middle part places a single star in each row, with the position of the star moving from right to left as the row number increases, creating the diagonal line of the Z. The outer loops handle the three parts separately, while the inner loops handle the spaces and stars in each row.