Prime visit code

sir,my prime visit code is able to pass test cases please tell me the change that i should to do.
#include
using namespace std;
#define ll long long
void primesieve(int p)
{
//1st mark all odd no as prime
for(int i=3;i<=10000;i+=2)
{
p[i]=1;
}
//sieve code
for(ll i=3;i<=10000;i+=2)
{
//if current no. is not marked
if(p[i]==1)
{
for(ll j=i
i;j<=10000;j=j+i)
{
p[j]=0;
}
}
}
//special case
p[2]=1;
p[0]=p[1]=0;
}
int main()
{
int n;
cin>>n;

int a,b;
int p[100000]={0};
while(n>0)
{
	int cnt=0;
	cin>>a>>b;
	primesieve(p);
	for (int i=a;i<=b;i++)
	{
		if(p[i]==1)
		{
			cnt++;
		}
	}
	cout<<cnt<<endl;
		n--;
 }
return 0;

}

hello @Abhishmu5
right now ur solution time complexity is very high, and it will give tle for most of the cases.
To optimise it maintain an array that will store number of index till each index and then use this array to answer each query in O(1).

refer this video editorial by prateek bhaiya-> https://www.youtube.com/watch?v=8sniiDbfPK4

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.