C Program to Check Given Number is PRIME or Not


main()
{
    int n, i;
    printf(“Enter an Integer Number to Find PRIME or Not  : “);
    scanf(“%d”, &n);
    for(i=2; i<=n/2; ++i)     {         if(n%i==0)         {             break;         }     }     if(i>n/2)
        printf(“%d is PRIME”,n);
    else
        printf(“%d is NOT PRIME”, n);
}

OUTPUT:

Enter an Integer Number to Find PRIME or Not : 23
23 is PRIME

Leave a Reply

Your email address will not be published. Required fields are marked *