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

Share To:

Arogya Thapa Magar

Post A Comment:

0 comments so far,add yours