C++ Program Finding Prime Numbers and Timing itself
<p>I am trying to write a c++ program that finds n prime numbers and times itself. I have already done this in 5 other languages using this logic. For some reason, this code does nothing. I am using the Code Blocks compiler. What causes this code not to work and how can I fix it? I am not very familiar with c++ so it will probably be something trivial.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;math.h&gt;
int main(){
    int n=10;
    int b=new int[n];
    int c=0;
    int d=2;
    while(c&lt;n){
        bool e=true;
        for(int i=0;i&lt;c;i++){
            if(d&lt;sqrt(b[i])){
                break;
            }
            if(d%b[i]==0){
                e=false;
                break;
            }
        }
        if(e){
            b[c]=d;
            c++;
        }
        d++;
    }
    for(int i=0;i&lt;c;i++){
        cout &lt;&lt; b[i]+"\n" &lt;&lt; endl;
    }
}
</code></pre>
