Created
August 11, 2014 22:12
-
-
Save metallurgix/bde7d6c631ae3e8d17a3 to your computer and use it in GitHub Desktop.
Day of the Week using Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
char* cal_day(int y, int m, int d) | |
{ | |
char* days[]={"Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday"}; | |
int a=(14-m)/12; | |
y=y-a; | |
m=m+12*a-2; | |
return days[ (d + y + y/4 - y/100 + y/400 + (31*m)/12) % 7]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment