/****************************************
*Namc:prj1 *
*Purpose:judge the prime number *
*Author:Bennett *
*Date written:1/19/2012 *
****************************************/
#include<stdio.h>
#include<stdbool.h> //C99 only
bool is_prime(int n){
int divisor;
if(n<=1) //both 0 and 1 are not prime or composite number
return false;
for(divisor=2;divisor*divisor<=n;divisor++)
{
if(n%divisor==0)
return false;
}
return true;
}
int main()
{
int n;
printf("Enter a number:");
scanf("%d",&n);
if(is_prime(n))
printf("The number %d you input is Prime !\n",n);
else
printf("The number %d you input is NOT Prime !\n",n);
return 0;
}