Manmohan loves pattern

i don,t get code for even rows please tell

@rakesh800650 hey rakesh I think there is a hint video of this question.

Sir I don’t get code for even rows from video plz elaborate code for even rows with dry run

@devwrath1999 so you need a logic to build the code okay wait.

@devwrath1999 hey rakesh refer this
manmohan loves 2

Sir thanks for solving my doubt
I get ur code
But sir I also want to understand code for even rows written in video can u make me understand sir

@devwrath1999 okay let me check

Sir plz solve my query

@rakesh800650
The first loop , the loop with the variable i is used to print the total rows of the pattern while the inner loop is used to print the pattern for each individual row.
There are total of n rows so we run the loop from i =1 till i<=n.
Length of each individual row is equal to the row number. So we run each inner loop from j=1 to j<=i as for ith row , its length is equal to i.
Inside each row, we see that we first have to print the row no. at the first and the last position so we print i-1 when j==0 and j==i .
For the remaining elements , we straight away have to print a 0.

Notice that we have handled the case for the first row as that is an exception over the pattern formed in the rest of the part so that needs to be handled separately as well.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.