Why my code is not passing the test cases

Hello @anshulgurawalia i have corrected your code;

i think that you just change the declarartion of array you make it globally

instead of making declaring array globally can i declare array in main function and pass to sieve function as as a parameter??

@anshulgurawalia locally you can make array of some size only i.e of 1e6 only.
thats why i have done like that only.
plus : for( int i=3;i<=1000005;i=i+2){
arr[i]=1;
}
in this also you were doing mistake you were not checking till 1000005.

how ??i have assigned all odd index to one from 3 to 1000005

@anshulgurawalia you were doing it for only till1005 .
this was the mistake:

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.