Why am I getting wrong answer for FLOW015?

#include<stdio.h>
int main()
{
int y,k,l,count=0,n,i,a=0;
scanf("%d",&n);

while(n–)
{
scanf("%d",&y);
if((1900<=y) && (y<2001))
{

if((y%100==0)&&(y%400!=0))
{
k=2000-y;
l=k/4;
count=(k+l+1)%7;
}
else
{
k=2000-y;
l=k/4;
count=(k+l+2)%7;
}

if(count==0)
{
printf(“monday\n”);

}
else if(count==1)
{
printf(“sunday\n”);

}
else if(count==2)
{
printf(“saturday\n”);

}
else if(count==3)
{
printf(“friday\n”);

}
else if(count==4)
{
printf(“thursday\n”);

}
else if(count==5)
{
printf(“wednesday\n”);

}
else if(count==6)
{
printf(“tuesday\n”);

}
}
else if((2001<=y) && (y<=2500))
{

k=y-2001;
i=(y/100)%10;
if(i/4>0)
{
a=i/4;
}
if((y%100==0)&&(y%400!=0))
{
i–;
}
l=(k/4)-i+a;
count=(k+l)%7;

if(count==0){printf(“monday\n”);}
else if(count==1)
{
printf(“tuesday\n”);

}
else if(count==2)
{
printf(“wednesday\n”);

}
else if(count==3)
{
printf(“thursday\n”);

}
else if(count==4)
{
printf(“friday\n”);

}
else if(count==5)
{
printf(“saturday\n”);

}
else if(count==6)
{
printf(“sunday\n”);

}
}
}
}

I didn’t check your code, but I suspect that there are test cases outside the range of years specified. I had a wrong answer on ths with code that should have worked if the years were restricted as stated - @admin any chance this could be checked?

It’s relatively easy though to extend the formulas to work on any dates from 1582 onwards.

//