Top baner Big

Your Ad Here

Top Banner

Your Ad Here

Saturday, November 22, 2008

Program to find a number prime or not

/*Program :Program to find a number prime or not
Programmer ::fizmhd(MEA) www.mdown.co.cc*/

#include

int prime_or_not(int);

int main()
{
int number,re;
printf("Enter the number : ");
scanf("%d",&number);
re=prime_or_not(number);
if(re==1)
printf("%d is not Prime\n",number);
else if(re==0)
printf("%d is Prime\n",number);
else
printf("It is neither prime nor composite\n");
}

int prime_or_not(int num)
{
int i;
if(num==0)
return 1;
if(num==1)
return -1;
for(i=2;ilt;=num/2;i++)
{
if(num%i==0)
return 1;
}
return 0;
}

No comments:

Easy Hits

EasyHits4U.com - Your Free Traffic Exchange - 1:1 Exchange Ratio, 5-Tier Referral Program. FREE Advertising!

Bottom Square