Doomsday algorithm

hey everyone, could you guys help me write out a particular code that involves the doomsday algorithm? I started trying but i have no clue what to do after the code im about to post. This is the overall question:

Implement a function called dayofmonth that accepts the month and the
year as parameters and returns the doomsday corresponding to that month (as
shown above). Also check for leap years.

Assume Sunday is 0, Monday is 1, Tuesday is 2, Wednesday is 3, Thursday
is 4, Friday is 5, and Saturday is 6. Write a function called doomsday that takes
the year as a parameter and returns the doomsday for that year.

Write a function called dayofweek that accepts the month, the day, and the
year as parameters and returns the day of the week. Your function will make
use of the previous two, and you will need to compute the offset between thegiven day and the result of dayofmonth


P.S. i know its a several part question but my knowledge in c++ is extremely minor as im learning it on my own. Any help is appreciated.

So i tried the problem and this is sort of what i have so far..

1
2
3
4
5
6
7
  #include <iostream>
  using namespace std;

int main(int argv, char** arv) {
    int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char* day[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};   
    int d, m, y, i;

Last edited on
Some minor edits:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;

int main(int argc, char** argv) {

    int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    char* day[] = {
        "Sunday", "Monday", "Tuesday", "Wednesday",
        "Thursday", "Friday", "Saturday"
    }; 
    int d, m, y, i;
    return 0;
}


This is a good start, but to receive further help, you have give more information. For example:

algorithm wrote:
...returns the doomsday corresponding to that month (as
shown above)


What is shown above?
Topic archived. No new replies allowed.