To print prime numbers between m and n when m and n are quite large in the range 10^10 using sieve of eratosthenes <p>My code is:</p> <pre><code>#include &lt;bits/stdc++.h&gt; #define s 100001 using namespace std; int main() { long long arr[s],i,j,t,m,n; for(i=0;i&lt;s;i++) arr[i] = 1; arr[0] = 0; arr[1] = 0; for(i=2;i&lt;sqrt(s);i++) { if(arr[i] == 1) { for(j=2;i*j&lt;s;j++) arr[i*j] = 0; } } cin &gt;&gt; t; while(t--) { cin &gt;&gt; m &gt;&gt; n; if(n&lt;s) { for(i=m;i&lt;=n;i++) { if(arr[i] == 1) cout &lt;&lt; i &lt;&lt; endl; } } } return 0; } </code></pre> <p>This code is showing run time error for larger input of m and n as the array size is just 10^5 long. When I was making the array of 10^10 there was a compilation error and it is showing this much bigger array is not possible.</p>