#include #include #include //for the functions time and localtime #include //for class string 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}; string a[] { "Sunday", //0 "Monday", //1 "Tuesday", //2 "Wednesday", //3 "Thursday", //4 "Friday", //5 "Saturday" //6 }; int n {size(a)}; //the number of elements in the array if (weekday < 0 || weekday >= n) { cerr << "Bad weekday " << weekday << " should have been in range 0 to 6 inclusive.\n"; return EXIT_FAILURE; } cout << a[weekday] << "\n"; //Output one of the strings in the array. return EXIT_SUCCESS; }