#include<stdio.h>
int if_a_is_prime(int d)
{
int c = 2;
for (c = 2; c<d ; c++)
{
if ( d%c == 0)
{
return 0;
}
}
return 1;

}

int main()
{
int a = 100;
int b = 0;
int count = 0;
for (a = 100; a <= 200; a++)
{

if ( if_a_is_prime(a)== 1)
{
printf("%d ", a);
count++;
}

}

printf("\n总共有%d个素数", count);
return 0;
}

程序:运用函数找出100至200的素数,并数出个数_c++