Assistance in fixing an almost-complete program?

So this program is supposed to take the day, month and year and be able to show you the weekday of that particular date. Problem is I always get the output 84 for some reason. Don't understand where that number is coming from or what I necessarily need to fix?

#include <iostream>
#include <string>
using namespace std;

int month (int mm)
{
    if (mm == 1)return 13;
    if (mm == 2)return 14;
    if (mm == 3)return 3;
    if (mm == 4)return 4;
    if (mm == 5)return 5;
    if (mm == 6)return 6;
    if (mm == 7)return 7;
    if (mm == 8)return 8;
    if (mm == 9)return 9;
    if (mm == 10)return 10;
    if (mm == 11)return 11;
    if (mm == 12)return 12;
}

int weekday_number (int wn)
{
    int mm;
    int d;
    int y;
    wn=(d+5+(((26*(mm + 1))/10)+((5*(y%100))/4)+((21*(y/100))/4)))%7;
    return wn;
}

int main()
{
    int d;
    int mm;
    int y;
    int wn;
    cout << "Please enter a date (Format: month/day/year) and I'll compute the weekday: " << endl;
    cout << "Date Example: 01/20/2012" << endl;
    cin >> mm >> d >> y;
    cout << wn << endl;
    if (wn == 0)
    {
    cout << "Monday";
    }
    else if (wn == 1)
    {
    cout << "Tuesday";
    }
    else if (wn == 2)
    {
    cout << "Wednesday";
    }
    else if (wn == 3)
    {
    cout << "Thursday";
    }
    else if (wn == 4)
    {
    cout << "Friday";
    }
    else if (wn == 5)
    {
    cout << "Saturday";
    }
    else if (wn == 6)
    {
    cout << "Sunday";
    }
    else
    {
    cout << "Error Occured" << endl;
    }
    system ("pause");
    return 0;
}
You aren't calling your functions in the main function.
How do you mean? I thought by using an if statement and typing "wn" it would take the result from the function?
In your main function,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
int d;
 int mm;
    int y;
    int wn;
    cout << "Please enter a date (Format: month/day/year) and I'll compute the weekday: " << endl;
    cout << "Date Example: 01/20/2012" << endl;
    cin >> mm >> d >> y;
    wn = weekday_number(d, mm, y);
    cout << wn << endl;
    if (wn == 0)
    {
    cout << "Monday";
    }
    else if (wn == 1)
    {
    cout << "Tuesday";
    }
    else if (wn == 2)
    {
    cout << "Wednesday";
    }
    else if (wn == 3)
    {
    cout << "Thursday";
    }
    else if (wn == 4)
    {
    cout << "Friday";
    }
    else if (wn == 5)
    {
    cout << "Saturday";
    }
    else if (wn == 6)
    {
    cout << "Sunday";
    }
    else
    {
    cout << "Error Occured" << endl;
    }
    system ("pause");
    return 0;
}


In your int weekday_number,

1
2
3
4
5
6
7
8
int weekday_number(int d, int mm, int y)
{
  int mm;
    int d;
    int y;
  return (   (d+5+(((26*(month(mm) + 1))/10)+((5*(y%100))/4)+((21*(y/100))/4)))%7   );
  
}
Oh ok thanks I see what you did! I'm new to all this and these things tend to fly by me.
bottom line is that functions won't 'activate' unless another function calls them.
Topic archived. No new replies allowed.