Pattern practice problem que nr 7 and 8

I am not able to think the logic …how to solve this que

Hi @Nilesh-Kumar-1173882276149322,
Take two variable number of space ->nsp and one as number of stars ->nst .And then lets say n = 5 so apply a for loop that runs 5 times and then in that put conditions using if statement to display the respective stars and space format accordingly . use that nst be equal to n and nsp to be 0 if the loop variable i is equal to 0 or n-1 otherwise take nst = 2 and nsp be n-2 if loop variable i is other than 0 or n-1.Similarly think for pattern 8.

1 Like