title: Prime Numbers Optimization in C
body: <p>I try to print the prime numbers; 2 to 1 million. But nothing printed on the console. Could you check my code? And how can I be this code more optimized?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  main()
  {
     int num, sr, num2;
  
     for (num = 2; num &lt;= 1000000; num++) {
        sr = (int) sqrt(num);
        for (num2 = 2; sr % num2 != 0; num2++) {
           if (sr == num2) {
              printf("%d\n", sr);
           }
        }
     }
  
  }
  </code></pre>