Monday, June 24, 2019

to find the given number is prime number or not ..c language

#include<stdio.h>
#include<math.h>

void main()
{
    int i,num,flag=1;
    printf("Enter a number \n");
    scanf("%d",&num) ;
    for(i=2;i<= sqrt(num);i++)
    {
        if (num%i==0)
        {
            printf("%d is not prime\n",num);
            flag=0;
            break;
        }
    }
    if (flag==1)
        printf ("%d is prime\n", num);
}

No comments:

Post a Comment

python class topic video