what is the switch in c++?

switch is an conditional statement where we can specify actions according to conditions.

Syntax:

switch (variable_name)
{
    case [condition_1]:  //statements...
                          break;
    case [condition_2]:  //statements
                          break;

          ...
          ...
    case [condition_n]: //  statements
                            break;
    default :    //statements
                              break;
}

Note : 1. condition's value must be the same data type of the variable_name
2. break statement must be given to prevent from execution of the next set of statements.