ADS

C Program To Find Prime Number Between 1 To N | C Programming

C Program To Find Prime Number Between 1 To N

#include<stdio.h>
int main()
{
    int  n,i,j,count;
    printf("Enter the Number:");
    scanf("%d",&n);
    printf("Prime number between %d to %d are\n",1,n);
    for(i=2;i<=n;i++)
    {
        count=1;
        for (j=2;j<=i/2;j++)
        {
            if (i%j==0)
            {
                count=0;
                break;
            }
        }
    if(count==1)
    {
        printf("%d  ",i);
    }
    }
    return 0;
}

OUTPUT
C Program To Find Prime Number Between 1 To N

Post a Comment

0 Comments