sum of primes under 2000000
<p>I'm trying this program to find the sum of all the primes under two million, but for some reason I am coming up with a number far below what I should be expecting.</p>

<p>Here is my code. A co-working says I might not be catching all the primes with my program but he doesn't know C++ and I don't see how I could be missing them.</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

int main()
{
    int a = 500000;
    int e = 0;

    // this is an array to hold all the prime number i find,
    // it's initialized to the arbitrarily high number of 500000
    int list[a]; 

    //here i am initializing the first members of my list to the first primes
    list[0] = 2; 
    list[1] = 3;
    list[2] = 5;
    a = 3; // i set a = 3 to catch the next coming prime of 7
    for (int c = 5; c &lt; 2000000; c++)
    {
        // this bool is for prime catching, 
        // if d is false then the number will not be saved into the array
        bool d = false; 

        // this bool is for an exit statement in the following iterative loop, 
        // if it's false the loop will exit
        bool h = true; 
        for (int i = 0; list[i] &lt; c/2 + 1 &amp;&amp; h == true; i++)
        {
            // this checks to see if a number is evenly 
            // divisable by any of my primes so far
            if (c % list[i] == 0) 
            {
                d = false;
                h = false;
            }
        }
        if (d == true)
        {
            list[a] = c; // if i find a prime i save it into my array
            e += c; // if i find a prime i sum it to my total
            a++;
        }
    }
    cout &lt;&lt; e; 
}
</code></pre>
