Day of the Week Program

I know the basics of what I need to do, but can't seem to get it all to work. I am using Visual C++ Express.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <string> 
using namespace std; 

int main(void)
{
  string Days[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday",
                  "Friday","Saturday"}; 
  int a,month,year,y,day,m,d;

  cout <<"Enter the month (1-12): ";
  cin >>month;
  cout <<"Enter the date (1-31): ";
  cin >>day;
  cout <<"Enter the year (>1582): ";
  cin >>year;

  cout <<endl <<"The Date: "<<month<<"/"<<day<<"/"<<year
       <<" Falls on a: "<< Days[d]<<endl;
  return 0;
}


Somewhere in there, there needs to be this algorithm (and I don't quite know where):

1
2
3
4
5
6
// Assume that month, day and year have been read in
	 
	a = (14-month)/12;
 	y=year-a;
	m = month+12*a-2; 
	d = (day+y+y/4-y/100+y/400+(31*m/12))%7; 

Is the rest of the code okay?
What are you trying to do?
You input any month, day, and year and the program will tell you what day (Sun, Mon, etc) that date falls on.
How do you plan on achieving that ?
Topic archived. No new replies allowed.