#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int range_of_choice = 0;
bool isprime;
do
{
cout<<"Enter a number greater than zero: "<<endl;
cin>>range_of_choice;
} while ( range_of_choice <= 0 );
for (int i = 2; i < range_of_choice; ++i)
{
isprime = true;
for (int j=2; j*j<=i; ++j)
{
if (i % j == 0)
{
isprime = false;
break;
}
}
if(isprime)
{
cout << i << " ";
}
}
char k;
cin>>k;
return 0;
}
I think they have this policy thing on this website where you have to show your attempt firsthand before having someone helping you with your exercise. Luckily for you though, such policies do not apply to me, i am sacrosanct. However, i do encourage you to type out your first attempt next time, it's for your own good. Or you could simply pm me, i'd love to do all your homework for you whenever you want (lol).