Pattern of numbers and zeroes

i am not able to print zeroes between the numbers

https://ide.codingblocks.com/s/103555 - this is the url of the code

@Ayushi21
Please share the HackerBlocks problem link. Your code seems like its for a Linked List mergesort problem but it doesn’t fit with your specified issue about the zeroes. I request you to provide me with the exact problem name or HackerBlocks link.

https://hack.codingblocks.com/contests/c/917/163 - this is the url of the question

@Ayushi21
Since I do have your code , I am going to suggest my approach for this question. If you want me to check your code , kindly share it or else you can simply go ahead and try this approach and then share your new code if you need any help with that either.

We are getting one input N in this question.
We have to print a pattern having N rows where ith row has i elements.
That is
1st row has 1 element
2nd row has 2 elements
3rd row has 3 elements and so on.

So the outer loop which controls the behaviour of total rows will run from 1 to N whereas the inner loop which has to print the data in each row will run from 1 to i

for(int i=1;i <= N; i++) {
for(int j=1;j <=i ; j++ ) {


}
}

As for the code inside the loop
We can observe that we are printing 0 everywhere in each row except for the beginning of the row and its end.
So ,
if( j == 1 or j == i) print i
else print 0

j==1 signifies the first element of each row and j == i signifies the last element. At these locations we print the row number = i
Otherwise we simply print 0.
Remember to give the spaces in between.

Try this code and let me know if you need help.

https://ide.codingblocks.com/s/104072 - is this what you are saying

@Ayushi21
The if else part needs to be inside the loops , inside the body of the inner loop.
Also by “print” I meant to show output .
Use cout << i and cout << 0 instead of print i and print 0.
Also put a space output after each integer and a new line space after every row i.e.
write the cout statements like
cout << i << " "; and cout << 0 << " "; to show the spaces and give a cout << endl ; after the inner loop but inside the outer loop like
for(int i=1;i <= N; i++) {
for(int j=1;j <=i ; j++ ) {
if( j == 1 or j == i) cout << i << " ";
else cout << 0 << " ";
}
cout << endl;
}

Try this code and let me know if you need any help.