Best way to ask if statement with multiple conditions?

48 Views Asked by At

I'm wondering if there is a more concise way to write this

if (answer == 'A' || answer == 'a') {
    std::cout << "Correct!\n";

   } else if (answer == 'B' || answer == 'C' || answer == 'D' || answer == 'b' || answer == 'c' || answer == 'd'){
      std::cout << "Wrong!\n";

   } else {
      std::cout << "Invalid option!\n";

under the else if middle section its just really bloated and annoying to type out. can I do something in the vain of:

else if (answer == (b||B||c||C||d||D||)) {
0

There are 0 best solutions below