```
# include<iostream.h>
# include<math.h>
void main()
{
int flag=0;
unsigned long l, h, temp;
cout<<"Enter the lower limit:"; cin>>l;
cout<<"Enter the higher limit:"; cin>>h;
if(l%2==0)
{
if(l==2) cout<<"2\t";
l++; //taking only odd no
}
for(;l<=h;l+=2, flag=0)
{
temp=sqrt(l);
if(temp%2==0) temp++; //taking only odd no
for(; temp>2; temp--)
{
if(l%temp==0)
{
flag=1;
break;
}
}
if(flag==0) cout<<l<<"\t";
}
}
```

Recommended Topics