{
int n;
cout << "Please enter a positive integer: " << endl;
cin >> n;
if (cin.fail())
{
cout << n << " is a bad integer." << endl;
}
cout << "The following numbers are all prime numbers between 2 and " << n << ": ";
for (int i = 2; i <= n; ++i)
{
//if i is prime, then print it.
bool iIsPrime = true;
for (int k = 2; k < i; ++k)
{
if (i % k == 0)
{
// i is not prime.
iIsPrime = false;
}
}
if (iIsPrime)
{
cout << i << " ";
}
}
cout << endl;
}