To k-1:
I found that there were a few problems with your code. It returns everything as a prime.
I tried changing ur code to this
int is_prime(int n, int z)
{
if((n%z)==0)
return 0;//should be 0
else
{
if(z<n)
return is_prime(n,z+1);
else
return 1;//should be one
}
}
I did so , bcos in MY code i actully printed "The number is prime" when the value returned by the func was 1(true); But still it didnt help. For the moment it merely printed "the number is NOT prime" for all cases.
Therefore, the problem that i found was actually in base case of the recursive function. z gets incremented to n and eventually n%n yields to 0; So i just added one more line in the beginning of the function:
int is_prime(int n, int z)
{
if(n==z) return 1;
else if((n%z)==0)
return 0;
else if(z<n)
return is_prime(n,z+1);
}