I am trying to write a program that tells what time it is (am or pm) and what day of week it is when the user enters an hour number between 0 and 167 (7 days Monday at midnight starts at 0)
Heres what I have so far. I am working on the days of the week:
Code:
7 #include <stdio.h>
8
9 int main(void)
10
11 {
12
13 int hour;
14 #define day (Monday || Tuesday || Wednesday || Thursday || Friday || Saturday || Sunday)
15
16 printf("Enter hours: ");
17 scanf("%d", &hour);
18
19 if (hour < 24)
20 day = Monday;
21 else if (hour > 23 || hour < 48)
22 day = Tuesday;
23 else if (hour > 47 || hour < 72)
24 day = Wednesday;
25 else if (hour > 71 || hour < 96)
26 day = Thursday;
27 else if (hour > 95 || hour < 120)
28 day = Friday;
29 else if (hour > 119 || hour < 144)
30 day = Saturday;
31 else ( hour > 143 || hour < 168)
32 day = Sunday;
33
34 printf("Result: %d\n", day);