Find remainder

#include
using namespace std;
int main()
{
int n,a,b,p;
cin>>n;
if(1<=n&&n<=1000)
{
for(int i=0;i<=n;i++)
{
cin>>a>>b;
p=a%b;
cout<<p<<"\n";
}
}
return 0;
}
WHat is wrong in the code

for(int i=0;i<=n;i++)

This executes n+1 times, I think you are taking more input than required.

You are right . May be you have to begin from i=1 .