Saturday, December 17, 2011

C Program for find a Prime Number...

#include<stdio.h>
#include<conio.h>

void main()
{
int i,j=2,ch=0;
clrscr();
       printf("\nENTER ANY NUMBER: ");
       scanf("%d",&i);
  while(j<=i/2)
       {
    if(i%j==0)
      {
            printf("%d IS NOT PRIME",i);
            ch=1;
            break;
          }
        else
          {
           j++;
          }
      }
 if(ch==0)
   {
   printf("%d IS PRIME",i);
   }
   getch();

}

No comments:

Post a Comment