PROGRAM
#include <iostream>
using namespace std;
int main()
{
int
lower,upper,i,flag,temp;
cout<<"Enter the starting range: ";
cin>>lower;
cout<<"Enter
the ending range: ";
cin>>upper;
if(lower>upper)
{
temp=lower;
lower=upper;
upper=temp;
}
if(lower>1 && upper>1)
{
cout<<"Prime numbers between
"<<lower<<" and "<<upper<<"are:
\n";
while(lower <= upper)
{
flag=1;
for(i=2 ; i<=(lower/2) ; i++)
{
if(lower%i==0)
{
flag=0;
break;
}
}
if(flag==1)
{
cout<<lower<<"\t";
}
lower++;
}
}
else
{
cout<<"Value(s) cannot be negative";
}
return 0;
}
OUTPUT