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'.
Loading...
Related Quiz
- The ______ keyword is used to define a condition in C++.
- Steve needs to ensure that a variable can only take on one of three values: RED, GREEN, or BLUE. What should he use in C++ to achieve this?
- Which statement is best suited for selecting one of many blocks of code to be executed?
- The expression a×b can be represented as a _______ b in C++.
- In C++, _______ functions cannot be virtual.