The next part is to determine and print the prime numbers between a user-specified lower bound and user-specified upper bound.

How exactly would I go about doing that?

I have read mytext and looked on net, and cant find anything... heres the code i have so far

it would have to be in the area of the

cout<<"Please enter a number: "; cin>>b;

#include <cstdlib> #include <iostream> #include <iomanip> #include <stdlib.h> using namespace std; const unsigned W = 10; int main(int argc, char *argv[]) { const unsigned arraySize = 500; bool a[arraySize]; unsigned b, x; unsigned counter = 0; cout<<"This program is programming assignemnt #5."<<endl; cout<<"THE SIEVE OF ERATOSTHENES."<<endl; cout<<"By Jeremy Rice of CSCI 111."<<endl; //Initializing elements to 1 for (int i = 0; i < arraySize; i++) { a[i] = 1; } // For array subscript 2, all elements beyond 2 in the array that // are multiples of 2 will be set to zero; for array subscript 3, // all elements beyond 3 in the array that // are multiples of 3 will be set to zero for (int i = 2; i * i < arraySize; i++) if (a[i]) for (int j = i + i; j < arraySize; j += i) a[j] = 0; // print all subscripts set to 1 cout<<"Please enter a number: "; cin>>b; for (int j = 2; j < b; j++) { if (a[j] == 1) { counter++; cout<<setw(W)<<counter + 1<<endl; } else counter++; } system("pause"); return 0; }

This post has been edited by **jrice528**: 20 November 2007 - 03:52 PM