For n = 7
Let's analyze this design line by line. We break this pattern into 5 components:
We also observe that the components first and fifth and second and fourth; are symmetrically flipped about the middle column. So, it is but obvious that the conditions we will place for segregating the first and second component will be just flipped opposite for getting the fifth and fourth component respectively. In the third component, we just have to print stars for all the columns of the middle row (n/2 +1 row).
The condition for First component will be: if( i == 1)
Second component: else if(i <= n/2)
Third component: else if( i == n/2 +1)
Fourth component: else if(i < n)
Fifth component: whatever is left constitutes the last row only. Looking into the first component:
We need to print stars only till middle column (n/2 +1) and last column (n).