Manmohan loves patterns 1

In the above question my testcase 2 is correct but the rest 3 test cases are wrong. Please help.
https://ide.codingblocks.com/s/53080

Hey Divyam, your code is not correct even for sample case

input:
6
your code’s output:
1
11
111
10001
11111
100001
your output’s 4th line is not printing the correct number of 0’s. Correct output should be
1
11
111
1001
11111
100001

Oh, got it. I added one 0 more in the rows. Will reduce it . Thanks!

https://ide.codingblocks.com/s/53080
Now only test case 3 is wrong. Why?

Hey Divyam, still your code is not satisfying the problem’s demand. See every row should have columns equal to that particular row’s number. So to correct this update your code’s line:15 like this
for (int k=0; k<i-2;k=k+1)

1 Like