Sunday, May 5, 2013

Prime number or not

#include<conio.h>

#include<stdio.h>

void main()

{

   int z,i;
   printf("enter a number");
   scanf("%d",&z);
   while
     {
       if(z%i==0)
         {
           break;
         }
         i=i+1;
     }
      if(i==z)
         {
            printf("%d is a prime number",z);
         }
      else
        {
          printf("%d is not prime",z);
        }
getch();
}    

No comments:

Post a Comment