Find number is prime or not

Sunday, March 13, 2016 Unknown 0 Comments

  • TO FIND THAT NUMBER IS PRIME OR NOT


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

void main()
{
          int no,a=2;
          printf("Enter any no:");
          scanf("%d",&no);

          while(a<no)
          {
                   if(no%a==0)
                   {
                            a=0;
                            break;
                   }
                   else
                   {
                            a++;
                    }
           }

           if(a==0)
                    printf("no. is prime");
           else
                    printf("no is not prime");
           getch();
}

Output : 

Enter any no:10
no. is prime

0 comments: