Not getting the answer

#include
using namespace std;
void primes(int *p){
for(int i=2;i<=1000000;i++){
p[i]=1;
}
p[1]=0;
p[0]=0;
for(int i=2;i<=1000000;i++){
if(p[i]==1){
for(int j=i^2;j<=1000000;j+=i){
p[j]=0;
}
}
}
return;
}
int cost(int n,int *p){
for(int i=0;i<=1000000;i++){
if(n==0){
return i;
}
if(p[i]){
n–;
}
}
}

int main() {
int pri[1000000];
primes(pri);
int t;
cin>>t;
while(t){
int n;
cout<<cost(n,pri)<<endl;

	t--;
}
return 0;

}

hey @Aayush-Mahajan-2206170693038609, please share your code saved in coding blocks ide.

hey @Aayush-Mahajan-2206170693038609, as contraints of questions are very high change all int to long long int

Still not getting the answer

hey @Aayush-Mahajan-2206170693038609, please share me your updated code.

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.