/* Program demonstrating the use of an enumerated type */ #include /* enumerated type definition */ typedef enum {monday, tuesday, wednesday, thursday, friday, saturday, sunday} day_t; // the first identifier is represented by the integer 0, // the second by 1, and so on void print_day(day_t day); int main(void) { double week_hours = 0.0, day_hours; day_t today; printf("The value of monday = %d\n",monday); printf("The value of friday = %d\n",friday); for ( today = monday; today <= friday; ++today){ printf("Enter hours for "); print_day(today); printf("> "); scanf("%lf",&day_hours); week_hours += day_hours; } printf("\nTotal weekly hours are %.2f\n",week_hours); return (0); } /* * Display string corresponding to a value of type weekday */ void print_day(day_t day) { switch (day) { case monday: printf("monday"); break; case tuesday: printf("tuesday"); break; case wednesday: printf("wednesday"); break; case thursday: printf("thuesday"); break; case friday: printf("friday"); break; case saturday: printf("saturday"); break; case sunday: printf("sunday"); break; default: printf("\n*** INVALID DAY CODE ***\n"); } }