Getting segmentation error in building the segment tree

here is the link to my code. I am unable to find out what I am doing wrong in it. --> https://ide.codingblocks.com/s/217512

@Yash-Mittal-2335533069896503,
Updated code: here
Correction: Line 8: return