#include<stdio.h>
int main()
{
int n,i,j,c=0;
printf("Enter any number\n");
scanf("%d",&n);
printf("Prime number between 1 and %d is\n1",n);
for(i=1;i<=n;i++)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
{
c++;
}
}
if(c==2)
{
printf(" %d",i);
}
}
}
OUTPUT
Enter any number
10
Prime number between 1 and 10 is
1 2 3 5 7
Comments
Post a Comment