Setting a max number in c++

Use an if statement:

if (hours < max_hours) {
  // Do stuff
}
else {
  std::cout << "Invalid Hours";
}

Leave a Comment