Sir my logic shows only infinite loop

@lokeshverma764 hi buddy,
check this code,
if ((row == 1) || (row == n))

            {

                star = 2;

            }

will it ever come out of the loop? Dry run it you will get it!

If still there is problem, lemme know!
Happy coding!

https://online.codingblocks.com/app/player/67586/content/139346/4772

@lokeshverma764 bro give me your changed code, and have you made a submission? paste your code in ide and send me the link, I will help you. And the above snippet which i posted from your code, that is where the problem is!

@lokeshverma764 hi bro here is your corrected code, i have also commented the changes carefully check em and compare with ya prev code.


Your code was cool, but some mistakes were there, else very good, keep practicing.
If your query is resolved close the doubt my marking it resolved.
Happy coding!

Thank you sir for help me in this.May you please sir elaborate why we need to initialize β€œtemp” in this code

@lokeshverma764 bro the reason is, you were initializing stars when row == 1 or row == n that would make it go in infinite loop for the first row itself, as stars will always have fixed value for row 1, so i want that only n / 2 stars should be printed, so i made a temp var to preserve previous nst value and changed nst in if, now i have to reinit nst to prev value, thats why! just dry run it for first two rows , you will get it!
And bro close the doubt if query is resolved. Work hard!
Happy coding!