What is wrong with this code?giving a segmentation error