#include #include #include //for the functions time and localtime using namespace std; int main() { //Get the current day of the week (0 to 6 inclusive, 0 means Sunday). time_t t {time(nullptr)}; tm *p = {localtime(&t)}; int weekday {p->tm_wday}; if (weekday == 0) { cout << "Sunday"; } else if (weekday == 1) { cout << "Monday"; } else if (weekday == 2) { cout << "Tuesday"; } else if (weekday == 3) { cout << "Wednesday"; } else if (weekday == 4) { cout << "Thursday"; } else if (weekday == 5) { cout << "Friday"; } else if (weekday == 6) { cout << "Saturday"; } else { //none of the above cerr << "Bad weekday " << weekday << " should have been in range 0 to 6 inclusive.\n"; return EXIT_FAILURE; } cout << "\n"; return EXIT_SUCCESS; }