Why i am getting segmentation fault in this?

#include
#include<stdio.h>
using namespace std;
void primeseive(int p)
{
long long int i,j;
for(i=3;i<=1000000; i+=2)
{
p[i]=1;
}
for( i=3; i<=1000000; i+=2)
{
if(p[i]==1)
{
for( j=i
i; j<=1000000; j=j+i)
{
p[j]=0;
}
}
}
p[1]=p[0]=0;
p[2]=1;

}
int main() {
int p[10000000]={0};
int i;
primeseive§;
for(i=1; i<=100; i++)
{
if(p[i]==1)
{
cout<<i<<" ,";
}
}
return 0;

}

hello @jatin_wadhwa
make ur p array global and then try

1 Like

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.