PRATEEK LOVES CANDY PROBLEM

I run it on my system its working fine but on coding blocks giving RUN ERROR

#include<bits/stdc++.h>
void sieve(int *p);
using namespace std;
int main()
{

 int p[10000]={0};
  sieve(p);

 int test;
 cin>>test;

 while(test--)
 {

     int a;
     cin>>a;

     int i=0, count=0;
     while(count!=a)
     {
         if(p[i]==1)
         {
             count++;
             if(count==a)
                cout<<i<<endl;
         }
         i++;

     }

 }

}

void sieve(int *p)
{

for(int i=3; i<10000; i=i+2)
p[i]=1;

for(int i=3; i<10000; i=i+2)
{
	if(p[i]==1)
	{
		for(int j= i*i; j<10000; j= j+i)
		p[j]=0;
	}
}
p[0]=p[1]=0; p[2]=1;

}