Design a program that will give the day of the week a date is on

Theres a mistake in my code somewhere because it is not working properly and I can not find the error. My program is written as follows and anything will be helpful. I needed to:
Decrement the year by 1 if the month is Jan or Feb,
otherwise keep it the same
Compute the rank as follows:
a.
Compute the following value: year + year/4 - year/1
00 + year/400 + month coefficient(given in a table for each month) +
day
b.
Find the remainder of the previous value when divid
ed by 7. You will get an integer
between 0 and 6 that will five the day ie 0:sunday 1:monday etc



#include <stdio.h>

int main() {
int month,day,year, mc,remainder,rank

;printf("Enter a date in the format month/day/year\n");
scanf("%d,%d,%d", &month, &day, &year);
if (month ==1)
year=year--;
else if (month ==2)
year=year--;
else
year=year;

switch (month){
case 1:mc=0;
break;
case 2:mc=3;
break;
case 3:mc=2;
break;
case 4:mc=5;
break;
case 5:mc=0;
break;
case 6:mc=3;
break;
case 7:mc=5;
break;
case 8:mc=1;
break;
case 9:mc=4;
break;
case 10:mc=6;
break;
case 11:mc=2;
break;
case 12:mc=4;
break;
default :printf("Enter a number for the month less than 13\n");
break;
}


rank=(year+(year*.25)-(year*.01)+(year*.04)+mc+day);
remainder=rank%7;

switch (remainder){
case 1:printf("This falls on a Sunday\n");
break;
case 2:printf("This falls on a Monday\n");
break;
case 3:printf("This falls on a Tuesday\n");
break;
case 4:printf("This falls on a Wednesday\n");
break;
case 5:printf("This falls on a Thursday\n");
break;
case 6:printf("This falls on a Friday\n");
break;
case 7:printf("This falls on a Saturday\n");
break;
default :printf("I don't know\n");
break;
}


;return 0;
}

Please use code brackets
Topic archived. No new replies allowed.