What will be the flow of control in a switch statement if there is no break keyword at the end of a case?

  • It will continue to execute the next case
  • It will return to the main function
  • It will terminate the switch statement
  • It will throw an error
In C/C++, if there's no break statement at the end of a case in a switch statement, the control will continue to execute the next case statements without any regard for the case conditions. This behavior is known as "fall-through." It's important to use break statements to avoid unintended fall-through.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *