Answer to Question #5908 in C++ for Kewal

Question #5908
write a function to take an int argument and return 0 if the given number is prime otherwise return -1.
1
Expert's answer
2012-01-06T10:29:48-0500
int isprime(int valuex)
{
int x,j;
x=1;
& for (j=2 ; j<valuex; j++)
{ if ((valuex%j)==0) x=0; }
& if(x!=0) return 0;
& else return (-1);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS