Sieve of Eratosthenes prime number finder up to n in C++
What you are doing here is first calculating primes under sqrt and then crossing out the multiples like sieve says. However the standard approach is to calculate primes as you go and cross out multiples of each prime :

vector&lt;bool&gt; isPrime(MAXIMUM, true);   //we only need bool, less memory usage

isPrime[0] = false;
isPrime[1] = false;

for (int i = 4; i &lt; MAXIMUM; i+=2) { // even numbers are handled first for efficiency
    isPrime[i] = false;
}

for(int i = 3; i &lt; MAXIMUM; i+=2){
    if (isPrime[i]) {
        //the usual is for(int j = i * 2; j &lt; MAXIMUM; j += i) { but I am using a bit more optimized loop
        for(int j = i * i; j &lt; MAXIMUM; j += 2 * i) {
            isPrime[j] = false;
        }
    } 
}

for(int x = 1; x&lt;MAXIMUM; x++){
    if(isPrime[x]){cout&lt;&lt; x &lt;&lt;'\t';}
}


This way code is much shorter and if you try it, also much faster.