link to my code --> https://ide.codingblocks.com/s/241641
@Arnav7, Code without segmentation fault, here.
but it is not sorting .
@Arnav7, Try dry run on paper and pen.