logoStarPatterns
Back to Patterns

Rhombus Pattern

Pattern Result

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

Code Implementation

Explanation

The Rhombus Pattern creates a parallelogram-like shape using asterisks. Each row contains the same number of stars, but each subsequent row is shifted to the right by adding one space at the beginning. The outer loop iterates from 0 to n-1, representing each row. For each row, we first add 'i' spaces to create the shifting effect, and then add n stars to create the rhombus shape.