#include #include #include //for the functions time and localtime using namespace std; int main() { //Get the current hour of the day (0 to 23 inclusive). time_t t {time(nullptr)}; tm *p {localtime(&t)}; int hour {p->tm_hour}; cout << "The current (24-hour) hour is " << hour << ".\n" << "The current (12-hour) hour is " << hour % 12 << " "; if (hour < 12) { cout << "a.m."; } else { cout << "p.m."; } cout << "\n"; //------------------------------------------------------- if (hour < 12) { cout << "Good morning\n"; } else if (hour < 12 + 6) { cout << "Good afternoon\n"; } else { cout << "Good evening\n"; } return EXIT_SUCCESS; }