Bob observed that in his program, even when the case for 'A' was satisfied in a switch statement, the program was also executing the case for 'B'. What could be the most probable reason?

  • Compiler error
  • Incorrect order of cases
  • Insufficient memory
  • Missing 'break' statement in case 'A'
In a switch statement, cases are executed sequentially unless a 'break' statement is encountered. If Bob's program was executing the case for 'B' even after 'A' was satisfied, the most probable reason is a missing 'break' statement in case 'A'.
Add your answer
Loading...

Leave a comment

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