According to the Gregorian calendar, it was Monday on the date 01/01/1900. If any year is input through the keyboard write a program to find out what is the day on 1st January of this year.
#include <stdio.h>enum days
{
Monday,Tuesday,wednesday,thursday,friday,saturday,sunday
};
int main (int argc, const char * argv[])
{
int sourceyear = 1900;
int currentyear;
printf("\nEnter the currentyear:"); scanf("%d",¤tyear);
int x = ((currentyear -sourceyear )%7);
switch (x)
{
case Monday:
printf("Monday");
break;
case Tuesday:
printf("Tuesday");
break;
case wednesday:
printf("wednesday");
break;
case thursday:
printf("thursday");
break;
case friday:
printf("friday");
case saturday:
printf("saturday");
case sunday:
printf("sunday");
default:
break;
}
return 0;
}
0 comments:
Post a Comment