Code:

#include <iostream.h>
#include <math.h>
void determinePrimes(int);
inline bool isPrime(int, int*);
int main()
{
int maxPrime;
cin >> maxPrime;
determinePrimes(maxPrime);
cout << "Done.";
return 0;
}
void determinePrimes(int maxPrime)
{
int *primes = new int[1.1 * (maxPrime / log10(maxPrime))]; primes[0] = 2;
for (int j = 3; j <= maxPrime; j += 2)
if (isPrime(j, primes)) primes[j-3] = j;
delete[] primes;
}
inline bool isPrime(int number, int *primes)
{
for (int j = 0; primes[j] < sqrt(number); ++j)
if (number % primes[j] == 0) return 0;
return 1;
}