Thursday, 19 December 2019

Prime Number in C

#include<stdio.h>
#include<conio.h>
int main()
{
int n,i,c=0;
printf("enter the number\n");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
    {
       if(n%i==0)
       {
         c=1;
         break;
       }
   }
    if(c==0)
printf("the number is  prime\n");
    else
    printf("the number is not prime\n");
return 0;
}

No comments:

Post a Comment

Convey your thoughts to authors.