Deepak and primes problem

i have tried to write the code for the given problem but it is giving segmentation fault after compilation. how to correct it to get the desired output ?

Now your code is working https://ide.codingblocks.com/s/270814