Pattern magic problem

can anybody please explain me the logic and provide me the code

Hi @bakshianjali49,
The given pattern is seen as first stars then spaces and then stars .So for each row do the work of stars fist , then that of spaces and then that of stars. And then change the variables accordingly for next iterations.

refer this code -->
https://ide.codingblocks.com/s/650459?_ga=2.59709869.1072852865.1671716885-672608080.1602772177