Home > Back-end >  Inquire of error
Inquire of error

Time:04-08

# include
Int main ()
{
Int x, isPrime=1, I;
The scanf (" % d ", & amp; X);
for(i=2; i{
If (x % I==0)
{
IsPrime=0;
break;
}
}
If (isPrime==0)
{
Printf (" is a prime number ");
}
The else
{
Printf (" is not a prime number ");
}
return 0;
}
Can you help me see which piece of wrong, is not

CodePudding user response:

In fact you is a sign of a set themselves a backwards, isPrime is not a prime number is equal to zero

CodePudding user response:

Reference:
 # include 
Int main ()
{
Int x, isPrime=1, I;
The scanf (" % d ", & amp; X);
If (x 1for(i=2; i{
If (x % I==0)
{
IsPrime=0;
break;
}
}
If (isPrime! (=0)//if isPrime==0) against here
{
Printf (" is a prime number ");
}
The else
{
Printf (" is not a prime number ");
}

return 0;
}
  • Related