User Input Date, Debug Output Day name

I need to make this program work so that I can input the date, month, day, and year. Then I need the debug to output the day be it sunday, monday, etc. This program must account for leap years and exceptions as I believe I have included with the equations. I basically really want to know how to connect my cases to the main code. I am new to coding and a bit confused on this.

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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
  #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>

void main()
{
	int daycode, month, day, year = 1;
	
	while (year > 0)
	{
		printf("Enter Month:  ");
		scanf("%d", &month);
		printf("Enter Day:  ");
		scanf("%d", &day);
		printf("Enter Year:  ");
		scanf("%d", &year);
		int numdays = ((year - 1) * 365 + ((year - 1) / 4) - ((year - 1) / 100) + ((year - 1) / 400));
		if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))		//check if leapyear
		
		if (month = 1)							// January 
			day = numdays;
		if (month = 2)							// February 
			day = numdays + 31;
		if (month = 3)							// March 
			day = numdays + 28 + 31 + 1;
		if (month = 4)							// April 
			day = numdays + 31 + 28 + 31 + 1;
		if (month = 5)							// May 
			day = numdays + 30 + 31 + 28 + 31 + 1;
		if (month = 6)							// June 
			day = numdays + 31 + 30 + 31 + 28 + 31 + 1;
		if (month = 7)							// July 
			day = numdays + 30 + 31 + 30 + 31 + 28 + 31 + 1;
		if (month = 8)							// August 
			day = numdays + 31 + 30 + 31 + 30 + 31 + 28 + 31 + 1;
		if (month = 9)							// September 
			day = numdays + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31 + 1;
		if (month = 10)							// October						
			day = numdays + 30 + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31 + 1;
		if (month = 11)							// November
			day = numdays + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31 + 1;
		if (month = 12)							// December
			day = numdays + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31 + 1;

		else
		
		if (month = 1)							// January 
			day = numdays;
		if (month = 2)							// February 
			day = numdays + 31;
		if (month = 3)							// March 
			day = numdays + 28 + 31;
		if (month = 4)							// April 
			day = numdays + 31 + 28 + 31;
		if (month = 5)							// May 
			day = numdays + 30 + 31 + 28 + 31;
		if (month = 6)							// June 
			day = numdays + 31 + 30 + 31 + 28 + 31;
		if (month = 7)							// July 
			day = numdays + 30 + 31 + 30 + 31 + 28 + 31;
		if (month = 8)							// August 
			day = numdays + 31 + 30 + 31 + 30 + 31 + 28 + 31;
		if (month = 9)							// September 
			day = numdays + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31;
		if (month = 10)							// October						
			day = numdays + 30 + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31;
		if (month = 11)							// November
			day = numdays + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31;
		if (month = 12)							// December
			day = numdays + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31 + 28 + 31;
	} 	
			printf("%d %d %d\n", month, day, year );
			
			
			switch (daycode)
			{
			case 0 :
			printf("Sunday");
			break;

			case 1 :
			printf("Monday");
			break;

			case 2 :
			printf("Tuesday");
			break;

			case 3 :
			printf("Wednesday");
			break;

			case 4 :
			printf("Thursday");
			break;

			case 5 : 
			printf("Friday");
			break;

			case 6 :
			printf("Saturday");
			break;
			}
	}
Last edited on
Topic archived. No new replies allowed.