Before:

// Validating the input of hour
cout << "Enter the hour (0- 23)" << endl;
cin >> hour;

while( !( hour >= 0 && hour <= 23 ) )
{
   cout << "Enter the hour (0 - 23)" << endl;
   cin >> hour;
}