Thank you in10se, ariels, mkb.
#include<stdio.h>
main()
{
int y; /* year */
int m; /* month */
int d; /* date (day) */
int newdate; /* day of the week */
printf("Please enter the year in question:\n");
scanf("%d", &y);
printf("Enter the number of the month:\n");
scanf("%d", &m);
if (m < 3)
{
m = m + 12;
y = y - 1;
}
printf("Enter the date: \n");
scanf("%d", &d);
newdate = (d + (2 * m) + ((6 * (m + 1)) / 10) + y + (y / 4) -
(y / 100) + (y / 400) + 1) % 7;
switch (newdate)
{
case 0:
{
puts("The day is Sunday.");
break;
}
case 1:
{
puts("The day is Monday.");
break;
}
case 2:
{
puts("The day is Tuesday.");
break;
}
case 3:
{
puts("The day is Wednesday.");
break;
}
case 4:
{
puts("The day is Thursday.");
break;
}
case 5:
{
puts("The day is Friday.");
break;
}
case 6:
{
puts("The day is Saturday.");
break;
}
default:
{
puts("You goofed!");
}
}
return 0;
}