I am trying to figure out when entering a date in the format of mm/dd/yyyy that it will output:
mm/dd/yyyy => (day of the week it was i.e. Monday, Tuesday)
So far, I have all my factors, I am missing something or several somethings. I also need to make this repeat so that I may keep entering in a date until a 0 is entered for mm or dd or yyyy.
please help. I dont know if i posted this right, apologies if it looks like garbage.Code:#define _CRT_SECURE_NO_WARNINGS #define numdays ((yyyy-1)*365+(yyyy-1/4)-(yyyy-1/100)+(yyyy-1/400)) #include <stdio.h> void main() { int mm; int dd; int yyyy; int numdays; int day; printf("Please enter date (m d y):"); scanf("%d %d %d", &mm, &dd, &yyyy); printf("%d/%d/%d =>", mm, dd, yyyy); switch(mm) { case 1: numdays +31; break;//Jan case 2: numdays +31+28; break;//Feb case 3: numdays +31+28+31; break;//Mar case 4: numdays +31+28+31+30; break; //Apr case 5: numdays +31+28+31+30+31; break; //May case 6: numdays +31+28+31+30+31+30; break;//Jun case 7: numdays +31+28+31+30+31+30+31; break;//Jul case 8: numdays +31+28+31+30+31+30+31+30; break; //Aug case 9: numdays +31+28+31+30+31+30+31+30+31; break;//Sep case 10: numdays +31+28+31+30+31+30+31+30+31+30; break;//Oct case 11: numdays +31+28+31+30+31+30+31+30+31+30+31; break; //Nov case 12: numdays +31+28+31+30+31+30+31+30+31+30+31+31; break; //Dec } day=numdays+dd; !yyyy%4 && !yyyy%100 || !yyyy%400; day+1; switch(day%7) { case 0: printf("Sunday\n"); break; case 1: printf("Monday\n"); break; case 2: printf("Tuesday\n"); break; case 3: printf("Wednesday\n"); break; case 4: printf("Thursday\n"); break; case 5: printf("Friday\n"); break; case 6: printf("Saturday\n"); break; } }



LinkBack URL
About LinkBacks


