The prompt is: Implement a function that reads in a string containing a textual description of a calendar date and that prints out the corresponding day of the week (Monday–Sunday). The two valid input formats for this function are:
mm/dd/yyyy
Example: 03/04/2014 Output: Tuesday
Month dd, yyyy
Example: March 04, 2014 Output: Tuesday
where dd is the numeric day, mm is the numeric month, yyyy is the year and Month is the name of the month. All days and months are specified using two digits (i.e. for March, use 03 instead of 3). In the second valid format, there is a single space between Month and dd and between dd, and yyyy. In order to receive full credit on this task, your program should print out the correct day of the week for any input in a correct format.
The code I have so far is able to give me the number of the day of the year that I input but from there I don't know what to do so that it will give me the day of the week because each year starts from a different weekday to begin with.
#include<stdio.h>
int main() {
int month, day, year, dm, dn, leap;
printf("enter the month:");
scanf("%d",&month);
printf("enter the day:");
scanf("%d",&day);
printf("enter the year:");
scanf("%d",&year);
if((year%100 == 0 && year%400 == 0) || (year%4==0)) {
if(month==1)
dm=0;
if(month==2)
dm=31;
if(month==3)
dm=60;
if(month==4)
dm=91;
if(month==5)
dm=121;
if(month==6)
dm=152;
if(month==7)
dm=182;
if(month==8)
dm=213;
if(month==9)
dm=244;
if(month==10)
dm=274;
if(month==11)
dm=305;
if(month==12)
dm=335;
}
else {
if(month==1)
dm=0;
if(month==2)
dm=31;
if(month==3)
dm=59;
if(month==4)
dm=90;
if(month==5)
dm=120;
if(month==6)
dm=151;
if(month==7)
dm=181;
if(month==8)
dm=212;
if(month==9)
dm=243;
if(month==10)
dm=273;
if(month==11)
dm=303;
if(month==12)
dm=334;
}
dn = dm+day;
printf("the day number is :%d",dn);
return 0;
}