Program :-
#include<stdio.h>
void main()
{
int n,j,i,f=1;
printf("enter the range of the number......!!!!\n");
scanf("%d",&n);
if(n>2)
{
printf("2\t");
}
for(i=3;i<=n;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
{
f=0;
break;
}
}
if(f==1)
printf("%d\t",i);
else
f=1;
}
}
Output :-