c++ nested switch statements

Nested Switch Statements in C++

#include <iostream>
using namespace std;

int main() {
   int x = 2;
   int y = 1;
   switch (x) {
      case 1:
         switch (y) {
            case 1:
               cout << "x is 1, y is 1";
               break;
            case 2:
               cout << "x is 1, y is 2";
               break;
         }
         break;
      case 2:
         switch (y) {
            case 1:
               cout << "x is 2, y is 1";
               break;
            case 2:
               cout << "x is 2, y is 2";
               break;
         }
         break;
   }
   return 0;
}
  1. Include the necessary header files and namespace.
  2. Define the main function.
  3. Declare variables x and y and initialize them.
  4. Start the outer switch statement with the variable x as its expression.
  5. Begin the first case of the outer switch statement with the value 1.
  6. Start the inner switch statement with the variable y as its expression.
  7. Define the cases inside the inner switch statement.
  8. Break out of the inner switch statement.
  9. Break out of the outer switch statement.
  10. Define the second case of the outer switch statement with the value 2.
  11. Start the inner switch statement with the variable y as its expression.
  12. Define the cases inside the inner switch statement.
  13. Break out of the inner switch statement.
  14. Break out of the outer switch statement.
  15. End the main function and return 0.