Gregorian Calendar

According to the Gregorian Calendar, it was monday on the date 01/01/1900. If any year is input through the keyboard write the program to find out what is the day on 1st January of the entered year.
1
2
3
4
5
6
7
8
9
10
11
12
// day of the week for january 1st
#include <iostream>
using namespace std;
int main ()
{
  char*week[]={"sun","mon","tue","wed","thu","fri","sat"};
  int year,days;
  cout<< "year?"; cin>>year;
  days = 365*year + (year-1)/4 - (year-1)/100 + (year-1)/400 ;
  cout<<week[days%7]<<"\n";
  return 0;
}
Topic archived. No new replies allowed.