Run-error in the code

#include
using namespace std;
int main() {
int sn[78498],g=1;
sn[0]=2;
int p[1000000];
p[0]=0;
p[1]=0;
p[2]=1;
for(int k=3;k<1000000;k++){
p[k]=1;
}

for(int i=3;i<1000000;i+=2)
{
    if(p[i]==1){
        sn[g]=i;
        g++;
        for(int j=i*i;j<1000000;j=j+2*i)
        p[j]=0;
    }
}
int tc;
cin>>tc;
int n[tc];

for(int m=0;m<tc;m++){
    cin>>n[m];
    int x=n[m];
    cout<<sn[x-1]<<endl;
}
return 0;

}

Hello @akshitmehta,

Always share your code using Online Coding Blocks IDE.
The way you have shared it may introduce many syntax errors to it.
Steps:

  1. Paste your code at https://ide.codingblocks.com/
  2. Save your code there.
  3. Share the URL generated.

Now, coming back to the code:
I have modified your code:

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.