Prime_Seive not running

#include
using namespace std;
typedef long long int ll;

void prime_seive(ll arr[])
{
for (ll i=3;i<=1005;i+=2)
{
arr[i]=1;
}
for (int i=3;i<=1005;i+=2)
{
if (arr[i]==1)
{
for (int j=i*i;j<=1005;j+=i)
{
arr[j]=0;
}
}
}
arr[0]=arr[1]=0;
arr[2]=1;
}

int main()
{
int t;
cin>>t;
while (t–)
{
ll k,l;
cin>>k>>l;
int n=k,m=l;
//cout<<n<<endl;
ll arr[1005]={0};
prime_seive(arr);
ll count=0;
//out<<n<<endl;
for (int i=n;i<=m;i++)
{
if (arr[i]==1)
{
count++;
}
}
cout<<count<<endl;;
}

return 0;

}

Why this code is giving error on code blocks ??

@Krishna-Kumar-1362299170640596 the size of your array is 1005, which means you cannot access the index 1005, but you are trying to do it. change the size to 1006 and the code works. But the constraints are quite big so you need to change the size accordingly.

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.