https://www.codechef.com/problems/PRIME1.
My code is just crashing before entering the values
#include<iostream>
#include<cmath>
#define y 10000000
using namespace std;
int main()
{
int t,x,j,i=0;
cin>>t;
int m,n;
int primes[y];
int prime[100000];
for(i=0;i<=sqrt(y);i++)
primes[i]=1;
primes[0]=0;
primes[1]=0;
for(i=2;i<=sqrt(y);i++)
{
if(primes[i]==1)
{
for(j=2;i*j<=sqrt(y);j++)
primes[i*j]=0;
}
}
while(t--)
{
cin>>m >>n;
i=2;
while(primes[i]==1)
{
x=(m/i)*i;
for(j=x;j<=n;j=j+i)
{
prime[j]=0;
}
for(j=m;j<=n;j++)
{
if(prime[j]==1)
cout<<j;
}
cout<<"\n";
i++;
}
}
return 0;
}