Just had a few problems. I also made the days an array of strings because it looks cooler and is probably better.
Code:
#include <stdio.h>
int main(void)
{
int temp, given_year, counter=1;
char theday[7][10] = { "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday",
"Sunday" };
printf("Enter the year\n");
scanf("%4d",&given_year);
if(given_year < 1900)
{
printf("Year has to be 1900 or above.");
return -1;
}
for(temp=1900;temp<=given_year;temp++)
{
if((temp-1)%4 == 0 && ((temp-1)%100 == 0 || (temp-1)%400 != 0))
{
if(counter<7)
counter+=2;
else
counter=2;
}
else
{
if(counter<=7)
counter++;
else
counter=1;
}
}
printf("%s",theday[counter-2]);
return 0;
}