Pls tell the mistake in this code

#include
using namespace std;

void optimisedPrimes(long long integer p,long long integer n,long long integer key)
{
for(long long integer i=2;i<=n;i++)
{
p[i]=1;
}
for(long long integer i=4;i<=n;i+=2)
{
p[i]=0;
}
for(long long integer i=3;i<=n;i+=2)
{
if(p[i])
{
for(long long integer j=i
i;j<=n;j+=i)
{
p[j]=0;
}
}
}
p[0]=0;
p[1]=0;
long long integer count=0;

for(long long integer i=0;i<=n;i++)
{
	if(p[i])
    {
	count++;
    if(count==key)
    {
        cout<<i;
    }
    }
}

}

int main()
{
long long integer p[5000000]={0};
long long integer key;
cin>>key;

optimisedPrimes(p,500000,key);

return 0;

}

hey @angivanshikaangi question ask you find max 500000th prime number. Now this surely at index greater than 500000 in prime seive.

Example if n=2, than also you need prime seive of least size 4 so that index i=3 will indicate prime number.

So increase the size of array.

yes i tried but i am still getting the error. I am still getting run time error
can u plss suggest me the corrections in the code
#include
using namespace std;

void optimisedPrimes(int p,long long int n,int key)
{
for(int i=2;i<=n;i++)
{
p[i]=1;
}
for(int i=4;i<=n;i+=2)
{
p[i]=0;
}
for(int i=3;i<=n;i+=2)
{
if(p[i])
{
for(int j=i
i;j<=n;j+=i)
{
p[j]=0;
}
}
}
p[0]=0;
p[1]=0;
int count=0;

for(int i=0;i<=n;i++)
{
	if(p[i])
    {
	count++;
    if(count==key)
    {
        cout<<i<<endl;
    }
    }
}

}

int main()
{
int p[100000000]={0};
int t;
cin>>t;
while(t–)
{
int key;
cin>>key;

optimisedPrimes(p,1000000000,key);
}

return 0;

}

hey @angivanshikaangi, please share me the code saved in codingblocks ide so that I debug it for you.

hey @angivanshikaangi, your prime seive is not correct. I have made changes to your code only. You can check them here. https://ide.codingblocks.com/s/105972

hey@Gaurav13998
i am still getting rum time error

hey @angivanshikaangi, these i,j, count, key, p all should also be of type long long int. Sorry I skipped that. Here is your modified code https://ide.codingblocks.com/s/105972

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.