SWITCH STATEMENTS IN C++

SAIROSHNI

 
Switch statement

Switch Statements 

  • The greatest substitute for the lengthy if statements that are used to compare a variable to several integral values are the switch statements in C++.
  • It also called multi-way branching statements. 
  • The control statement known as the switch statement enables any value to alter the execution's direction. 
  • The expression in the switch statement of c++ is valid only if it results in a constant value.
  • The duplicate case values are not allowed in a switch statements.

Syntax:

switch(expression)
{
case:1
//code block
break;
case:2
//code block
break;
default;
//code block
}

Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send