How to use Nested S...
 

How to use Nested Switch statements in C++  


Gnana
Posts: 25
(@gnana)
Eminent Member
Joined: 3 months ago

Please provide me the Nested Switch statements syntax of C++.
I need it very urgent…

1 Reply
admin
Posts: 93
Admin
(@mjv119gmail-com)
Member
Joined: 5 years ago

You can have a switch as part of the statement sequence of an outer switch. Even if the case constants of the inner and outer switch contain common values, no conflicts arise.

switch(x) {
   case 1:
      switch(y) {
                   case 0: printf("example by spytm.com");
                   break;
                   case 1: example(a,b);
                }
      break;
   case 2: printf("example 2 by spytm.com");
      break;
}
Reply

Leave a reply


 
Preview 0 Revisions Saved
Share: