C PROGRAM TO FIND PRIME NUMBERS UPTO N

 HI! FRIENDS

TO FIND PRIME NUMBERS UPTO N:

CODE:

#include<stdio.h>

int main()

{

int i,j,n,count;

printf("Enter n");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

    count=0;

    for(j=1;j<=i;j++)

    {

        if(i%j==0)

        {

            count++;

        }

    }

    if(count==2)

    printf("%d ",i);

}


return 0;

}


you can copy and compile the code by below link:

Click to compile

HAPPY CODING!!...

Post a Comment