You are on page 1of 1

Try to divide this question into two parts.

Firstly, print the upper half of the


diamond pattern and then the lower half.
There will be two loops, one for the upper half i.e. (n+1)/2, and the other for the
lower half i.e. for the rest n/2 lines.
When currRow=1,
For the first-half number of spaces would be (n/2) + 1 - currRow and the number of
stars would be (2 * currRow) - 1).
For the second half we re-initialize currRow with 1 then,
For the second-half number of spaces would be currRow and the number of stars would
be 2 * ((n/2) - currRow + 1) - 1
For example, if N=5, then the pattern would look like this,

I am unable to make logic please help me


can you make a call for better understanding

You might also like