My code is not working if i increase array size;
Hey @aryanraj you need to change your loop for sieve slightly. This is the changed code
int seive[n+1]={0};
seive[0]=seive[1]=1;
for(int i=2;i*i<=n;i++){
if(seive[i]==0){
for(int j=i*i;j<=n;j+=i){
seive[j]=1;
}
}
}
Now the for i's where sieve[i]=0 are the prime numbers. In first for loop I changed the break condition to i*i<=n instead of i<n.