Prateek Loves Candy please tell me the right way

#include
using namespace std;

int main() {

int T,  N, a[100000]={0}, i, j,  count=0;
cin>>T;

a[2]=0;

for(i=3; i<=100000; i+=2)
{
	a[i]=1;
}

for(i=3; i<=100000; i+=2)
{
	if(a[i])
	{
		for(j=i*i; j<=100000; j+=2*i)
		{
			a[i]=0;
		}
	}
}

for(i=0; i<T; i++)
{
	cin>>N;
	count=1;

	for(j=2; j<=100000; j++)
	{
		if(a[i]==1)
		{
			count++;
		}
		if(count==N)
			break;
		
	}
	cout<<j<<endl;
}
return 0;

}

your code is correct except one thing
a[i]=0;
instead of this you have to write a[j]=0;
in nested loop