Converting into a function help

Hello guys!

I'm new at programming and have some problems converting this exercise into a function.

This is an exercise i've made, but now i need to make it into a function, i have tried as seen as a comment here.

The exercise is about saying which day of the week it is, from date,month,year and century.


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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 #include <iostream>

using namespace std;

int main()
{
    int m,d,y,c,x=0,z;
    cout << "This program will tell you the day of the inputs:" << endl;
    cout << "What is the day of the month?: "<< endl;
    cin >> d;


    cout << "What is the number of the month from the months table?: "<< endl;
    cout << "Jan, Oct = 0"<< endl;
    cout << "May = 1"<< endl;
    cout << "Aug = 2"<< endl;
    cout << "Feb, Mar, Nov = 3"<< endl;
    cout << "Jun = 4"<< endl;
    cout << "Sep, Dec = 5"<< endl;
    cout << "Apr, Jul = 6"<< endl;
    cout << "Exceptions: If it is a leap year, Feb = 2 and Jan = 6"<< endl;
    cin >> m;


    cout << "What is the last 2 digits in the year?: "<< endl;
    cin >> y;


    cout << "What is the century's number in the 100s of years table?: "<< endl;
    cout << "14th century: 6" << endl;
    cout << "15th century: 5" << endl;
    cout << "16th century: 4" << endl;
    cout << "17th century: 3" << endl;
    cout << "18th century: 2" << endl;
    cout << "19th century: 1" << endl;
    cout << "20th century: 0" << endl;
    cin >> c;



    x=(d+m+y+(y/4)+c);
    z=x%7;
    cout << x << "Is now divided by 7" << endl << "The day of the week is: " << z << endl;

    cout << "The days of the week: " << endl;

    if(z==0)
    {
        cout << "The day of the week is: saturday";
    }
    if(z==1)
    {
        cout << "The day of the week is: sunday";
    }
    if(z==2)
    {
        cout << "The day of the week is: monday";
    }
    if(z==3)
    {
        cout << "The day of the week is: tuesday";
    }
    if(z==4)
    {
        cout << "The day of the week is: wednesday";
    }
    if(z==5)
    {
        cout << "The day of the week is: thursday";
    }
    if(z==6)
    {
        cout << "The day of the week is: friday";
    }







    return 0;
}
Last edited on
Topic archived. No new replies allowed.