-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWeekDay.c
43 lines (35 loc) · 973 Bytes
/
WeekDay.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
According to the Georgian Calendar, it was Monday on the date 01/01/01.
If any year is input throught eh keyboard, WAP to find out what is the day on 1st January of this year.
*/
#include<stdio.h>
int main() {
int d=1,y,i;
printf("Enter the Year: ");
scanf("%d", &y);
for (i=1;i<y;i++) {
if (i % 100 != 0 && i % 4 == 0)
d+=366;
else if (y % 400 == 0)
d+=366;
else
d+=365;
}
if (d%7==1)
printf("01/01/%.4d is Monday",y);
else if (d%7==2)
printf("01/01/%.4d is Tuesday", y);
else if (d%7==3)
printf("01/01/%.4d is Wednesday", y);
else if (d%7==4)
printf("01/01/%.4d is Thursday", y);
else if (d%7==5)
printf("01/01/%.4d is Friday", y);
else if (d%7==6)
printf("01/01/%.4d is Saturday", y);
else if (d%7==0)
printf("01/01/%.4d is Sunday", y);
else
printf("Invalid Input");
return 0;
}