C program to print all prime number up to given number
#include<stdio.h>
int main( )
{
int n, i, k, j;
printf("Enter the number");
scanf("%d",&n);
printf("Prime number upto %d are\n",n);
for(j=2; j<=n; j++)
{
k=0;
for(i=2; i<=j-1; i++)
{
if(j%i==0)
k++;
}
if(k==0)
printf("%d\n",j);
}
return 0;
}
0 Comments