布尔值没弄懂,请解释一下
#include<stdio.h>#include<stdbool.h>
int main(void)
{
unsigned long num;
unsigned long div;
bool isprime;
printf("please enter an integer for analysis;");
printf("Enter q to quit.\n");
while (scanf_s("%lu", &num) == 1)
{
for (div = 2, isprime = true; (div * div) <= num; div++)
{
if (num % div == 0)
{
if ((div * div) != num)
printf("%lu is divisible by %lu and %lu.\n",
num, div, num / div);
else
printf("%lu is divisible by %lu.\n", num, div);
isprime = false;
}
}
if (isprime)
printf("%lu is prime.\n", num);
printf("please enter another integer for analysis;");
printf("Enter q to quit.\n");
}
printf("Bye.\n");
return 0;
}
isprime = true,isprime = false;,if (isprime)的作用是什么,请详细解释一下,谢谢。