Why my code is saying segmentation fault?

Problem : Check Prime (HackerBlocks)