ENTER THE DATE AND SEARCH THE DAY(PAST AND FUTURER)
#include < stdio.h >
#include < conio.h >
void main() {
int sd, sm, sy, day, r, y, i, l = 0, sel = 0;
clrscr();
printf("first you diside are you find past are future\n");
printf("press 1 to past\n");
printf("press 2 to future\n");
scanf("%d", & sel);
printf("enter searching date");
scanf("%d%d%d", & sd, & sm, & sy);
if (sel == 1) {
y = 2011 - sy;
for (i = sy; i <= 2011; i++)
{
if (i % 4 != 0)
continue;
else
l++;
}
} else {
y = sy - 2011;
for (i = 2011; i <= sy; i++)
{
if (i % 4 != 0) {
continue;
} else {
l++;
}
}
}
if (sm == 1) {
day = sd;
}
if (sm == 2) {
day = sd + 31;
}
if (sm == 3) {
day = sd + 59;
}
if (sm == 4) {
day = sd + 90;
}
if (sm == 5) {
day = sd + 120;
}
if (sm == 6) {
day = sd + 151;
}
if (sm == 7) {
day = sd + 181;
}
if (sm == 8) {
day = sd + 212;
}
if (sm == 9) {
day = sd + 243;
}
if (sm == 10) {
day = sd + 273;
}
if (sm == 11) {
day = sd + 304;
}
if (sm == 12) {
day = sd + 334;
}
if (sy < 2011) {
day = day - y;
day = day - l;
}
if (sy > 2011) {
day = day + y;
day = day + l;
}
r = day % 7;
if (r == 1)
printf("saturday");
if (r == 2)
printf("sunday");
if (r == 3)
printf("monday");
if (r == 4)
printf("tuesday");
if (r == 5)
printf("wednesday");
if (r == 6)
printf("thursday");
if (r == 0)
printf("friday");
getch();
}
Comments
Post a Comment