Where my code is wrong?

@goelsparsh277 when you do this image
the array is initialised like {-1, 0, 0, 0, 0…}
so you need to iterate over all the elements to initialise it with -1. You can use the memset() function as well.

https://ide.codingblocks.com/s/296375 same result

hi @goelsparsh277 the memset function was not working properly, see the output now