Answers for "c++ nested switch statements"

C++
0

c++ nested switch statements

switch(ch1) {
   case 'A': 
      cout << "This A is part of outer switch";
      switch(ch2) {
         case 'A':
            cout << "This A is part of inner switch";
            break;
         case 'B': // ...
      }
      break;
   case 'B': // ...
}
Posted by: Guest on July-26-2021
0

c++ nested switch statements

#include <iostream>
using namespace std;
 
int main () {
   // local variable declaration:
   int a = 100;
   int b = 200;
 
   switch(a) {
      case 100: 
         cout << "This is part of outer switch" << endl;
         switch(b) {
            case 200:
               cout << "This is part of inner switch" << endl;
         }
   }
   cout << "Exact value of a is : " << a << endl;
   cout << "Exact value of b is : " << b << endl;
 
   return 0;
}
Posted by: Guest on July-26-2021

Browse Popular Code Answers by Language