Search & Find out

Saturday, November 21, 2009

Prime or not

#include "stdio.h"
#include "conio.h"

void main()
{
void prime(int);
int num;
clrscr();

printf("Enter a number : ");
scanf("%d",&num);
prime(num);
getch();

}
void prime(int x)
{
int i;
if(x==0||x==1)
{
printf("the no is neither prime nor composite");
}
else
{
   for(i=2;i
  {
     if(x%i==0)
     {
       printf("\nThe number is not a prime number, it is a composite number");
       break;
     }
   }
    if(x==i)
    {
      printf("\nThe number is a prime number");
    }
}
}


Download the executable (.exe)  file for this program..
download

0 comments:

Post a Comment

 

My Blog List

Term of Use