hi i'm new to c and i've had trouble with the following code i got from a tutorial. i get 'warning assignment to int from double' when trying to compile. if anyone could help as i'd like to know what i've done wrong or if its the compiler.
Code:
int main(void) //code to find the next prime number
{
int startingpoint, last, i, isprime, candidate;
startingpoint=19; //find the next prime after 19 in this case
if(startingpoint < 2)
{
candidate= 2;
}
else if(startingpoint ==2)
{
candidate =3;
}
else
{
candidate=startingpoint;
if( candidate %2 ==0)
candidate--;
do
{
isprime= true;
candidate +=2;
last = sqrt(candidate);
for(i=3; (i<= last) && isprime; i+=2)
{
if((candidate %i)== 0)
isprime= false;
}
}while( ! isprime);
}
printf("the next prime after %d is %d. happy?\n", startingpoint, candidate);
std::cin.get();
return 0;
}