What is Nested Switch Case in C ?

what is nested switch case in c ?

 In this article we will cover remaining topic of switch statement like,

  • What is Nested Switch Case in C ?
  • Syntax of Nested Switch Case in C
  • Example of Nested Switch Case in C

What is Nested Switch Case in C ?

A nested switch case is nothing but,When one or more switch statement are declared within the another switch statement such situation are called nested switch statement in C.

Syntax of Nested Switch Case in C

Switch(expression_1)

{
     case value-1:
              block-1

     switch(expression_2)

     {
           case value-2:
                    block-2
                    break;

           case value-3:
                    block-3
                    break;
              .
              .
              .

           case value-n
                   block-n
                   break;

           default:
                   default-block
                   break;  
      }
break;

default:
        default-block
        break;
}
statement-x;

Example of Nested Switch Case in C


Example of nested switch statement

Conclusion:

In this article we have learned about Nested Switch Statement in detail with their syntax and example, I hope after reading this article you have no any doubt remain but, Still if you have any doubt then feel free comment below.

Post a Comment (0)
Previous Post Next Post