I am unable to resolve this issue in my code which is making my output different from the question

See when you are in the last row there is one extra star being printed by the last loop … So for case n=5 we print 5 stars when loop runs from cst=1 to cst<=5 … That means for cst =1 it prints one star then for cst =2 it prints one star and so on … Now extra star problem only arises when the row = n .So what if we run the last loop one less time whenever row = n . So we intitialize cst = 2 when row = n so that it prints one star for cst=2 and then for cst=3 and so on till cst = 5 … Now see the pattern that earlier the stars were being printed 5 times when cst was initialized as 1 but if we initialize it as 2 it will run one less time so we will get 4 stars now instead of 5.