Why this code is not working, logic and everything seems to be correct

source code-> https://ide.codingblocks.com/s/231290

@the.shubham.sri inside your merge() function when you are copying temp[] back to the a[] your for loop should run till i<=end you are running it till i<end.