I am writing a program, and I am not sure what I need to do next. I am new to C, but I compiled the program and it didn't come up with any errors, I just don't quite understand what I need to do next. The purpose of the program is to give the day of a date (Sunday, Monday, etc). For example, I want the program to tell me that 10-11-2007 is a Thursday.
Code:
#include <stdio.h>
int main()
{
int month, day, year, prevyear, numdays;
printf("Please enter a date for month-day-year: ");
scanf("%d-%d-%d", &month, &day, &year);
prevyear = ((year - 1) * 365 + ((year - 1)/4) - ((year - 1)/100) + ((year - 1)/400)) % 7;
numdays = 0;
switch(month)
{
case 12:
numdays += 30;
case 11:
numdays += 31;
case 10:
numdays += 30;
case 9:
numdays += 31;
case 8:
numdays += 31;
case 7:
numdays += 30;
case 6:
numdays += 31;
case 5:
numdays += 30;
case 4:
numdays += 31;
case 3:
if ((!(year % 4) && (year % 100)) || ! (year % 400))
numdays += 29;
else numdays += 28;
case 2:
numdays += 31;
return(0);
}
switch(day)
{
case 6:
printf("The day was Saturday");
break;
case 5:
printf("The day was Friday");
break;
case 4:
printf("The day was Thursday");
break;
case 3:
printf("The day was Wedensday");
break;
case 2:
printf("The day was Tuesday");
break;
case 1:
printf("The day was Monday");
break;
case 0:
printf("The day was Sunday");
break;
}
return(0);
}
When I compile, it asks for a date, so I enter a date, but obviously it doesn't do anythin else. If anyone could help with this, I would appreciate it. Showing me what I need to do next to get me going in the right direction would be great.