What is the problem in this code

#include<bits/stdc++.h>
using namespace std;
long long int n=1000;
void prime_sieve(long long int *p,long long int n)
{

for(long long int i=3;i<n;i+=2)
{
    p[i]=1;            // all odd are prime
}
for(long long int i=3;i<n;i++)
{
    for(long long int j=i*i;j<n;j+=i)
    {
        p[j]=0;         // because they are divisible
    }
}
p[2]=1;
p[1]=0;
p[0]=0;

}
int main()
{
int l;
cin>>l;
while(l–)
{
long long int t;
cin>>t;
//cin>>n;
long long int p[n];
vectorv;
prime_sieve(p,n);
for(long long int i=0;i<n;i++)
{
if(p[i]==1)
{
v.push_back(i);
//cout<<i<<" ";
}
}
cout<<v[t-1]<<endl;
}
}

Hi @rohitkandpal683
Since we have to find the nth prime number
so we do not just run the seive till n since n will not be the nth prime no

refer the below code

Is there any doubt with the approach?

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.