Why my code is giving segmentation fault?

I’m trying to query in the segment trees. But, it is giving segmentation fault.

I am not able to find out the error, Plz help me find it.

Here’s the link to my code: https://ide.codingblocks.com/s/343834

hi @siddharth_1_3277 for which input did you try?

The program is not taking any user input.

@siddharth_1_3277 you’ve updated the program, earlier it was taking input for n.
Anyhow,
image
here size of tree array is 30 but your loop is going till 40.

1 Like

Yeah…Got it.Thanks

1 Like

@siddharth_1_3277 please mark your doubt as resolved :slight_smile:

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.