I see. Thanks. I now have the following, which seems to do the job.
Code:
#include <iostream>
using namespace std;
// print out the primes smaller than the user's chosen number
int main ()
{
int n, ii;
cout << "Enter a number between 1 and 1000: ";
cin >> n;
if (n > 2) {
cout << "2";
for (int i = 3; i < n; i++) {
for (ii = 2; ii <= i/2; ii++) {
if (i % ii == 0) break;
}
if (ii == i/2 + 1) cout << ", " << i;
}
cout << "\n";
}
return 0;
}